226 lines
6.8 KiB
Ruby
226 lines
6.8 KiB
Ruby
keybind 23 do |_event|
|
|
run "firefox"
|
|
end
|
|
|
|
keybind 24 do |event|
|
|
X.kill event[:window]
|
|
end
|
|
|
|
keybind 25 do |_event|
|
|
run "kitty"
|
|
end
|
|
|
|
keybind 26 do |_event|
|
|
run File.join(__dir__, "../shell/power.sh")
|
|
end
|
|
|
|
keybind 123, 0 do |_event|
|
|
run %q(
|
|
pactl set-sink-volume @DEFAULT_SINK@ +5%;
|
|
vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1);
|
|
dunstify "Volume Adjusted" "" -h int:value:$vol -r 997
|
|
)
|
|
end
|
|
|
|
keybind 122, 0 do |_event|
|
|
run %q(
|
|
pactl set-sink-volume @DEFAULT_SINK@ -5%;
|
|
vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\+%' | head -n1);
|
|
dunstify "Volume Adjusted" "" -h int:value:$vol -r 997
|
|
)
|
|
end
|
|
|
|
keybind 121, 0 do |_event|
|
|
run %q(
|
|
pactl set-sink-mute @DEFAULT_SINK@ toggle;
|
|
vol=$(pactl get-sink-volume @DEFAULT_SINK@ | grep -o '[0-9]\\+%' | head -n1);
|
|
dunstify "Volume Adjusted" "" -h int:value:$vol -r 997
|
|
)
|
|
end
|
|
|
|
keybind 38 do |_event|
|
|
run %Q(
|
|
maim -c 0.3,0.5,1.0,0.8 -s | tee /tmp/screenshot_temp.png | xclip -selection clipboard -t image/png;
|
|
if [ -s '/tmp/screenshot_temp.png' ]; then
|
|
mv /tmp/screenshot_temp.png ~/screenshots/$(date +%Y-%m-%d_%H:%M:%S).png;
|
|
fi
|
|
)
|
|
end
|
|
|
|
keybind 232, 0 do |_event|
|
|
run %q(
|
|
brightnessctl set 5%-;
|
|
pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %');
|
|
dunstify "Brightness" "" -h int:value:$pct -r 998
|
|
)
|
|
end
|
|
|
|
keybind 233, 0 do |_event|
|
|
run %q(
|
|
brightnessctl set 5%+;
|
|
pct=$(brightnessctl -m | cut -d, -f4 | tr -d ' %');
|
|
dunstify "Brightness" "" -h int:value:$pct -r 998
|
|
)
|
|
end
|
|
|
|
keybind 54 do |_event|
|
|
run "kitty -e fish -c \"y\""
|
|
end
|
|
|
|
keybind 53 do |_event|
|
|
run "kitty -e fish -c \"editor\""
|
|
end
|
|
|
|
keybind 40 do |_event|
|
|
run File.join(__dir__, "../shell/run.sh")
|
|
end
|
|
|
|
keybind 33 do |_event|
|
|
run "~/.config/polybar/launch.sh"
|
|
end
|
|
|
|
keybind 45 do |_event|
|
|
run File.join(__dir__, "../shell/caffiene.sh")
|
|
end
|
|
|
|
keybind 56 do |_event|
|
|
monitor = current_monitor
|
|
create_workspace monitor
|
|
persistence_path = File.join(__dir__, ".num.json")
|
|
persistence = File.exist?(persistence_path) ?
|
|
JSON.parse(File.read(persistence_path), symbolize_names: true) :
|
|
{}
|
|
persistence[$monitors.key(monitor)] ||= {}
|
|
persistence[$monitors.key(monitor)][:length] = monitor[:workspaces].length
|
|
File.write(persistence_path, JSON.pretty_generate(persistence))
|
|
end
|
|
|
|
keybind 57 do |_event|
|
|
monitor = current_monitor
|
|
delete_workspace monitor[:workspaces].length - 1, monitor
|
|
persistence_path = File.join(__dir__, ".num.json")
|
|
persistence = File.exist?(persistence_path) ?
|
|
JSON.parse(File.read(persistence_path), symbolize_names: true) :
|
|
{}
|
|
persistence[$monitors.key(monitor)] ||= {}
|
|
persistence[$monitors.key(monitor)][:length] = monitor[:workspaces].length
|
|
File.write(persistence_path, JSON.pretty_generate(persistence))
|
|
end
|
|
|
|
keybind 110, 0 do |_event|
|
|
run %q(
|
|
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Pause;
|
|
dbus-send --print-reply --dest=$(busctl --user list | grep -oP 'org.mpris.MediaPlayer2.firefox.instance_1_\\d+') \
|
|
/org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
|
|
)
|
|
end
|
|
|
|
keybind 110 do |_event|
|
|
monitor = current_monitor
|
|
persistence_path = File.join(__dir__, ".num.json")
|
|
persistence = File.exist?(persistence_path) ?
|
|
JSON.parse(File.read(persistence_path), symbolize_names: true) :
|
|
{}
|
|
if monitor[:selected_workspace] == 0
|
|
select_workspace persistence[$monitors.key(monitor)]&.[](:saved) || 1, monitor
|
|
else
|
|
persistence[$monitors.key(monitor)] ||= {}
|
|
persistence[$monitors.key(monitor)][:saved] = monitor[:selected_workspace]
|
|
File.write(persistence_path, JSON.pretty_generate(persistence))
|
|
select_workspace 0, monitor
|
|
end
|
|
end
|
|
|
|
keybind 115 do |event|
|
|
monitor = current_monitor
|
|
persistence_path = File.join(__dir__, ".num.json")
|
|
persistence = File.exist?(persistence_path) ?
|
|
JSON.parse(File.read(persistence_path), symbolize_names: true) :
|
|
{}
|
|
ws = monitor[:workspaces][
|
|
monitor[:selected_workspace] == 0 ?
|
|
monitor[:workspaces][persistence[$monitors.key(monitor)]&.[](:saved) || 1] : 0
|
|
]
|
|
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
|
|
end
|
|
|
|
keybind 118, 0 do |_event|
|
|
run "dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause"
|
|
end
|
|
|
|
keybind 117, 0 do |_event|
|
|
monitor = current_monitor
|
|
next if monitor[:selected_workspace].zero?
|
|
next_ws = (monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1
|
|
select_workspace next_ws, monitor
|
|
end
|
|
|
|
keybind 117 do |event|
|
|
monitor = current_monitor
|
|
next if monitor[:selected_workspace].zero?
|
|
ws = monitor[:workspaces][(monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1]
|
|
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
|
|
end
|
|
|
|
keybind 112, 0 do |_event|
|
|
monitor = current_monitor
|
|
next if monitor[:selected_workspace].zero?
|
|
next_ws = ((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1
|
|
select_workspace next_ws, monitor
|
|
end
|
|
|
|
keybind 112 do |event|
|
|
monitor = current_monitor
|
|
next if monitor[:selected_workspace].zero?
|
|
ws = monitor[:workspaces][((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1]
|
|
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
|
|
end
|
|
|
|
keybind 27 do |_event|
|
|
load File.join(__dir__, "./bindings.rb")
|
|
monitor = current_monitor
|
|
next unless monitor
|
|
monitor[:workspaces][monitor[:selected_workspace]].switch_direction
|
|
end
|
|
|
|
keybind 55 do |_event|
|
|
run "rofi -modi 'clipboard:greenclip print' -show clipboard -run-command '{cmd}'"
|
|
end
|
|
|
|
keybind 39 do |event|
|
|
window = $windows[event[:window]]
|
|
window.toggle_floating if window
|
|
end
|
|
|
|
mousebind 1
|
|
|
|
mousebind 3
|
|
|
|
mousebind 9, 0 do |_event|
|
|
monitor = current_monitor
|
|
next if monitor[:selected_workspace].zero?
|
|
next_ws = (monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1
|
|
select_workspace next_ws, monitor
|
|
end
|
|
|
|
mousebind 9 do |_event|
|
|
monitor = current_monitor
|
|
next if monitor[:selected_workspace].zero?
|
|
ws = monitor[:workspaces][(monitor[:selected_workspace] % (monitor[:workspaces].length - 1)) + 1]
|
|
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
|
|
end
|
|
|
|
mousebind 8, 0 do |_event|
|
|
monitor = current_monitor
|
|
next if monitor[:selected_workspace].zero?
|
|
next_ws = ((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1
|
|
select_workspace next_ws, monitor
|
|
end
|
|
|
|
mousebind 8 do |_event|
|
|
monitor = current_monitor
|
|
next if monitor[:selected_workspace].zero?
|
|
ws = monitor[:workspaces][((monitor[:selected_workspace] - 2) % (monitor[:workspaces].length - 1)) + 1]
|
|
ws.drop ws.tiled_windows.length, $windows[event[:window]] if $windows[event[:window]]
|
|
end
|