Skip to content

Instantly share code, notes, and snippets.

@doitian
Created August 26, 2010 14:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doitian/551432 to your computer and use it in GitHub Desktop.
Save doitian/551432 to your computer and use it in GitHub Desktop.
List windows for gpicker.
#!/usr/bin/env ruby
workspaces = {}
`wmctrl -d`.each_line do |line|
columns = line.split
if columns[7] == "N/A"
workspace_name = columns[8..-1].join(" ")
else
workspace_name = columns[9..-1].join(" ")
end
workspaces[columns.first.to_i] = workspace_name
end
windows = []
`wmctrl -x -l`.each_line do |line|
id, workspace_id, resource_class, host, *title = line.split
title = title.join(" ")
workspace = workspaces[workspace_id.to_i] || workspace_id
win_class = resource_class.split(".").last
unless win_class == "Gpicker" || workspace == "NSP"
# replace /
workspace.gsub!(/\//, " ")
title.gsub!(/\//, " ")
windows << "#{id}/#{workspace}/#{win_class} #{title}"
end
end
print windows.join("\0")
@doitian
Copy link
Author

doitian commented Apr 29, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment