sane-input-handler: factor out the side effects from the mapping
This commit is contained in:
@@ -274,6 +274,68 @@ proc toggleKeyboard {
|
||||
}
|
||||
}
|
||||
|
||||
proc togglePlayback {
|
||||
effect playerctl play-pause
|
||||
}
|
||||
|
||||
proc volumeUp {
|
||||
effect wpctl set-volume '@DEFAULT_AUDIO_SINK@' "$VOL_INCR"%+
|
||||
}
|
||||
|
||||
proc volumeDown {
|
||||
effect wpctl set-volume '@DEFAULT_AUDIO_SINK@' "$VOL_INCR"%-
|
||||
}
|
||||
|
||||
proc restartBonsai {
|
||||
effect systemctl restart bonsaid
|
||||
}
|
||||
|
||||
proc seekForward {
|
||||
effect playerctl position 30+
|
||||
}
|
||||
|
||||
proc seekBackward {
|
||||
effect playerctl position 10-
|
||||
}
|
||||
|
||||
proc killWindow {
|
||||
effect swamsg kill
|
||||
}
|
||||
|
||||
proc takeScreenshot {
|
||||
effect sane-open --application sane-screenshot.desktop
|
||||
}
|
||||
|
||||
proc openCamera {
|
||||
effect sane-open --auto-keyboard --application "$CAMERA"
|
||||
}
|
||||
|
||||
proc rotateCCW {
|
||||
effect swaymsg -- output '-' transform 90 anticlockwise
|
||||
}
|
||||
|
||||
proc rotateCW {
|
||||
effect swaymsg -- output '-' transform 90 clockwise
|
||||
}
|
||||
|
||||
proc openFilebrowser {
|
||||
effect sane-open --auto-keyboard --application rofi-filebrowser.desktop
|
||||
}
|
||||
|
||||
proc openFilebrowserWithApps {
|
||||
# reset fs directory: useful in case you get stuck in broken directory (e.g. one which lacks a `..` entry)
|
||||
effect rm -f ~/.cache/rofi/rofi3.filebrowsercache
|
||||
effect sane-open --auto-keyboard --application rofi.desktop
|
||||
}
|
||||
|
||||
proc openTerminal {
|
||||
effect sane-open --auto-keyboard --application xdg-terminal-exec.desktop
|
||||
}
|
||||
|
||||
proc killRofi {
|
||||
effect killall -9 rofi
|
||||
}
|
||||
|
||||
## DISPATCHERS
|
||||
|
||||
proc dispatchDefault (action) {
|
||||
@@ -284,14 +346,14 @@ proc dispatchDefault (action) {
|
||||
}
|
||||
("power_hold") {
|
||||
# power twice => toggle media player
|
||||
handleWith effect playerctl play-pause
|
||||
handleWith togglePlayback
|
||||
}
|
||||
|
||||
/ ^ 'volup_tap_' d+ $ / {
|
||||
handleWith effect wpctl set-volume '@DEFAULT_AUDIO_SINK@' "$VOL_INCR"%+
|
||||
handleWith volumeUp
|
||||
}
|
||||
/ ^ 'voldown_tap_' d+ $ / {
|
||||
handleWith effect wpctl set-volume '@DEFAULT_AUDIO_SINK@' "$VOL_INCR"%-
|
||||
handleWith volumeDown
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,13 +366,13 @@ proc dispatchOff (action) {
|
||||
}
|
||||
("power_tap_1_hold") {
|
||||
# power tap->hold: escape hatch for when bonsaid locks up
|
||||
handleWith effect systemctl restart bonsaid
|
||||
handleWith restartBonsai
|
||||
}
|
||||
/ ^ 'volup_hold_' d+ $ / {
|
||||
handleWith effect playerctl position 30+
|
||||
handleWith seekForward
|
||||
}
|
||||
/ ^ 'voldown_hold_' d+ $ / {
|
||||
handleWith effect playerctl position 10-
|
||||
handleWith seekBackward
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -322,34 +384,32 @@ proc dispatchOn (action) {
|
||||
("power_tap_1_hold") {
|
||||
# power tap->hold: kill active window
|
||||
# TODO: disable this if locked (with e.g. schlock, swaylock, etc)
|
||||
handleWith effect swaymsg kill
|
||||
handleWith killWindow
|
||||
}
|
||||
("power_and_volup") {
|
||||
# power (hold) -> volup: take screenshot
|
||||
handleWith effect sane-open --application sane-screenshot.desktop
|
||||
handleWith screenshot
|
||||
}
|
||||
("power_and_voldown") {
|
||||
# power (hold) -> voldown: open camera
|
||||
handleWith effect sane-open --auto-keyboard --application "$CAMERA"
|
||||
handleWith openCamera
|
||||
}
|
||||
("power_then_volup") {
|
||||
# power (tap) -> volup: rotate CCW
|
||||
handleWith effect swaymsg -- output '-' transform 90 anticlockwise
|
||||
handleWith rotateCCW
|
||||
}
|
||||
("power_then_voldown") {
|
||||
# power (tap) -> voldown: rotate CW
|
||||
handleWith effect swaymsg -- output '-' transform 90 clockwise
|
||||
handleWith rotateCW
|
||||
}
|
||||
|
||||
("volup_tap_1") {
|
||||
# volume up once: filesystem browser
|
||||
handleWith effect sane-open --auto-keyboard --application rofi-filebrowser.desktop
|
||||
handleWith openFilebrowser
|
||||
}
|
||||
("volup_hold_1") {
|
||||
# volume up hold: browse files and apps
|
||||
# reset fs directory: useful in case you get stuck in broken directory (e.g. one which lacks a `..` entry)
|
||||
rm -f ~/.cache/rofi/rofi3.filebrowsercache
|
||||
handleWith effect sane-open --auto-keyboard --application rofi.desktop
|
||||
handleWith openFilebrowserWithApps
|
||||
}
|
||||
|
||||
("voldown_start") {
|
||||
@@ -359,7 +419,7 @@ proc dispatchOn (action) {
|
||||
("voldown_hold_1") {
|
||||
# hold voldown to launch terminal
|
||||
# note we already triggered the keyboard; that's fine: usually keyboard + terminal go together :)
|
||||
handleWith effect sane-open --auto-keyboard --application xdg-terminal-exec.desktop
|
||||
handleWith openTerminal
|
||||
}
|
||||
("voldown_tap_1") {
|
||||
# swallow, to prevent keyboard from also triggering media controls
|
||||
@@ -376,7 +436,7 @@ proc dispatchInhibited (action) {
|
||||
case (action) {
|
||||
("power_tap_1_hold") {
|
||||
# power hold: escape hatch in case rofi has hung
|
||||
handleWith effect killall -9 rofi
|
||||
handleWith killRofi
|
||||
}
|
||||
(else) {
|
||||
# eat everything else (and let rofi consume it)
|
||||
|
Reference in New Issue
Block a user