Skip to content

Instantly share code, notes, and snippets.

@meise
Created December 4, 2012 12:39
Show Gist options
  • Save meise/4203395 to your computer and use it in GitHub Desktop.
Save meise/4203395 to your computer and use it in GitHub Desktop.
script to capture current i3 workspace
bindsym $mod+Shift+S exec /usr/local/bin/screenshot
#!/usr/bin/env ruby
# encoding: utf-8
require 'json'
require 'pathname'
WORKSPACES = JSON.load(`i3-msg -t get_workspaces`)
STORAGE_LOCATION = Pathname(ENV['HOME'] + '/screenshots')
WORKSPACES.each do |workspace|
next unless workspace['visible']
image_path = STORAGE_LOCATION + "#{workspace['num']}.#{rand(0-9999)}.png"
%x{ i3-msg workspace #{workspace['name']} }
sleep 1
%x{ import -window root #{image_path} }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment