left: refactor with argc
Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
parent
75b1043ac4
commit
5464089948
4 changed files with 37 additions and 17 deletions
|
@ -132,7 +132,7 @@ in {
|
|||
(key "Bracketright" "Super" "layoutmsg" "orientationnext")
|
||||
(key "Bracketright" "Super+Shift" "splitratio" "+0.1")
|
||||
(key "Delete" "Super" "exec" "${swayosd-client} --output-volume mute")
|
||||
(key "Delete" "Super+Shift" "exec" "${left} kensington-orbit-wireless-tb-mouse")
|
||||
(key "Delete" "Super+Shift" "exec" "${left} --scroll kensington-orbit-wireless-tb-mouse")
|
||||
(key "Down" "Super" "movewindow" "d")
|
||||
(key "Down" "Super+Shift" "movewindoworgroup" "d")
|
||||
(key "Equal" "Super" "exec" "${swayosd-client} --output-volume raise")
|
||||
|
|
|
@ -61,7 +61,7 @@ in {
|
|||
|
||||
# https://wiki.hyprland.org/Configuring/Keywords/#executing
|
||||
exec = [
|
||||
left # Set left-pawed state
|
||||
"${left} --init --scroll kensington-orbit-wireless-tb-mouse" # Enforce left-pawed state
|
||||
"${sleep} 5 && ${systemctl} --user restart walker"
|
||||
"${sleep} 5 && ${systemctl} --user restart waybar"
|
||||
];
|
||||
|
|
|
@ -92,6 +92,7 @@ in {
|
|||
systemd
|
||||
])
|
||||
(bash "left" [
|
||||
argc
|
||||
hyprland
|
||||
jq
|
||||
libnotify
|
||||
|
|
|
@ -1,35 +1,54 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
# Toggle left-pawed mouse
|
||||
#?? left DEVICE
|
||||
# @describe Toggle device pawdedness
|
||||
#
|
||||
# https://github.com/sigoden/argc
|
||||
|
||||
# BUG: New hyprctl syntax does not support per-device getoption
|
||||
# https://github.com/hyprwm/hyprlang/issues/43
|
||||
# HACK: Condition based on file presence, requires execution at reload to set state
|
||||
#?? exec = left
|
||||
FILE="$HOME/.left"
|
||||
#?? exec = left --init <DEVICE>
|
||||
|
||||
# Set initial state
|
||||
if [[ -f "$FILE" ]]; then
|
||||
# @arg device! Device name, obtained via hyprctl devices
|
||||
# @option -f --file=`_default_file` Specify file for state
|
||||
# @flag -i --init Enforce file-based state without switching
|
||||
# @flag -s --scroll Also invert scroll direction
|
||||
|
||||
_default_file() {
|
||||
echo "$HOME/.left"
|
||||
}
|
||||
|
||||
eval "$(argc --argc-eval "$0" "$@")"
|
||||
|
||||
# Get initial state
|
||||
if [[ -f "${argc_file:-}" ]]; then
|
||||
left=1
|
||||
else
|
||||
left=0
|
||||
fi
|
||||
|
||||
# If device argument, then toggle
|
||||
if (("$#" > 0)); then
|
||||
left=$((1 - "$left"))
|
||||
# If not initializing
|
||||
if [[ ! "${argc_init:-}" ]]; then
|
||||
left=$((1 - "$left")) # Toggle 0/1
|
||||
fi
|
||||
|
||||
# Enforce state
|
||||
if (("$left")); then
|
||||
hyprctl keyword "device[$1]:left_handed" true
|
||||
hyprctl keyword "device[$1]:natural_scroll" true
|
||||
touch "$FILE"
|
||||
hyprctl keyword "device[${argc_device:-}]:left_handed" true
|
||||
|
||||
if [[ "${argc_scroll:-}" ]]; then
|
||||
hyprctl keyword "device[${argc_device:-}]:natural_scroll" true
|
||||
fi
|
||||
|
||||
touch "${argc_file:-}"
|
||||
notify-send "> left" "Left-pawed" --urgency low
|
||||
else
|
||||
hyprctl keyword "device[$1]:left_handed" false
|
||||
hyprctl keyword "device[$1]:natural_scroll" false
|
||||
rm --force "$FILE"
|
||||
hyprctl keyword "device[${argc_device:-}]:left_handed" false
|
||||
|
||||
if [[ "${argc_scroll:-}" ]]; then
|
||||
hyprctl keyword "device[${argc_device:-}]:natural_scroll" false
|
||||
fi
|
||||
|
||||
rm --force "${argc_file:-}"
|
||||
notify-send "> left" "Right-pawed" --urgency low
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue