class Hiraishin
Attributes
current_shortcuts[R]
Public Class Methods
add_shortcut_to_cinnamon(name, command, *keys)
click to toggle source
# File lib/hiraishin.rb, line 5 def self.add_shortcut_to_cinnamon(name, command, *keys) `gsettings set org.cinnamon.desktop.keybindings custom-list "[#{current_shortcuts.join(', ')}, 'custom#{last_shortcode_number}']"` `gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom#{last_shortcode_number}/ name "#{name}"` `gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom#{last_shortcode_number}/ command "#{command}"` `gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom#{last_shortcode_number}/ binding "['<Primary>#{format_keys(keys)}']"` p "Shortcut #{format_keys(keys)} ('#{name}') created for #{command}" true end
Private Class Methods
current_shortcuts()
click to toggle source
# File lib/hiraishin.rb, line 22 def self.current_shortcuts @current_shortcuts ||= `gsettings get org.cinnamon.desktop.keybindings custom-list`.chomp[1..-2]&.split(', ') end
format_keys(keys)
click to toggle source
# File lib/hiraishin.rb, line 18 def self.format_keys(keys) [keys[0..-2].map{ |key| "<#{key}>" }.join, keys[-1].downcase].join end
last_shortcode_number()
click to toggle source
# File lib/hiraishin.rb, line 26 def self.last_shortcode_number last_keybinding = current_shortcuts.sort.last (last_keybinding[-2].to_i + 1).to_s end