Created
August 26, 2010 14:03
-
-
Save doitian/551432 to your computer and use it in GitHub Desktop.
List windows for gpicker.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See post Switch Window Using Fuzz Matching