#{{{ Clipboard
def_settings "clipboard/no_of_buff,refresh_period,selection,sel_buffer,selected}" do |wmii|
wmii.plugin_config["ollis-plugins:clipboard"]["no_of_buff"] ||= 10
wmii.plugin_config["ollis-plugins:clipboard"]["refresh_period"] ||= 1
wmii.plugin_config["ollis-plugins:clipboard"]["selection"] = ''
wmii.plugin_config["ollis-plugins:clipboard"]["sel_buffer"] = Array.new
wmii.plugin_config["ollis-plugins:clipboard"]["mouseclick_prog"] ||= "true"
end
bar_applet("clipboard", 50) do |wmii, bar|
Thread.new do
loop do
selection ||= `wmiipsel`.strip # wmiipsel is much faster than xclip
if selection != wmii.plugin_config["ollis-plugins:clipboard"]["selection"]
LOGGER.debug "new selection: #{selection}"
wmii.plugin_config["ollis-plugins:clipboard"]["selection"] = selection
wmii.plugin_config["ollis-plugins:clipboard"]["sel_buffer"].push(selection)
wmii.plugin_config["ollis-plugins:clipboard"]["sel_buffer"].uniq!
if wmii.plugin_config["ollis-plugins:clipboard"]["sel_buffer"].length > wmii.plugin_config["ollis-plugins:clipboard"]["no_of_buff"]
wmii.plugin_config["ollis-plugins:clipboard"]["sel_buffer"].shift
end
end
sleep(wmii.plugin_config["ollis-plugins:clipboard"]["refresh_period"] || 1)
end
end
end
binding("clipboard_print", "MODKEY-Shift-h") do |wmii,|
LOGGER.debug "clipboard_print called!!!"
system wmii.plugin_config["ollis-plugins:clipboard"]["mouseclick_prog"]
end
binding("clipboard_select", "MODKEY-h") do |wmii,|
LOGGER.debug "clipboard_select called!!!"
Thread.new do
list = Array.new
wmii.plugin_config["ollis-plugins:clipboard"]["sel_buffer"].each do |curr|
list.push(curr.gsub("\n", " "))
end
result = wmii.wmiimenu(list.reverse) do |choice|
if(choice.length > 0)
obj_id = list.rindex(choice)
selection = wmii.plugin_config["ollis-plugins:clipboard"]["sel_buffer"][obj_id]
system "echo '#{selection}' | xclip -i"
end
end
end
end