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" "layoutmsg" "orientationnext")
|
||||||
(key "Bracketright" "Super+Shift" "splitratio" "+0.1")
|
(key "Bracketright" "Super+Shift" "splitratio" "+0.1")
|
||||||
(key "Delete" "Super" "exec" "${swayosd-client} --output-volume mute")
|
(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" "movewindow" "d")
|
||||||
(key "Down" "Super+Shift" "movewindoworgroup" "d")
|
(key "Down" "Super+Shift" "movewindoworgroup" "d")
|
||||||
(key "Equal" "Super" "exec" "${swayosd-client} --output-volume raise")
|
(key "Equal" "Super" "exec" "${swayosd-client} --output-volume raise")
|
||||||
|
|
|
@ -61,7 +61,7 @@ in {
|
||||||
|
|
||||||
# https://wiki.hyprland.org/Configuring/Keywords/#executing
|
# https://wiki.hyprland.org/Configuring/Keywords/#executing
|
||||||
exec = [
|
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 walker"
|
||||||
"${sleep} 5 && ${systemctl} --user restart waybar"
|
"${sleep} 5 && ${systemctl} --user restart waybar"
|
||||||
];
|
];
|
||||||
|
|
|
@ -92,6 +92,7 @@ in {
|
||||||
systemd
|
systemd
|
||||||
])
|
])
|
||||||
(bash "left" [
|
(bash "left" [
|
||||||
|
argc
|
||||||
hyprland
|
hyprland
|
||||||
jq
|
jq
|
||||||
libnotify
|
libnotify
|
||||||
|
|
|
@ -1,35 +1,54 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
# Toggle left-pawed mouse
|
# @describe Toggle device pawdedness
|
||||||
#?? left DEVICE
|
#
|
||||||
|
# https://github.com/sigoden/argc
|
||||||
|
|
||||||
# BUG: New hyprctl syntax does not support per-device getoption
|
# BUG: New hyprctl syntax does not support per-device getoption
|
||||||
# https://github.com/hyprwm/hyprlang/issues/43
|
# https://github.com/hyprwm/hyprlang/issues/43
|
||||||
# HACK: Condition based on file presence, requires execution at reload to set state
|
# HACK: Condition based on file presence, requires execution at reload to set state
|
||||||
#?? exec = left
|
#?? exec = left --init <DEVICE>
|
||||||
FILE="$HOME/.left"
|
|
||||||
|
|
||||||
# Set initial state
|
# @arg device! Device name, obtained via hyprctl devices
|
||||||
if [[ -f "$FILE" ]]; then
|
# @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
|
left=1
|
||||||
else
|
else
|
||||||
left=0
|
left=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If device argument, then toggle
|
# If not initializing
|
||||||
if (("$#" > 0)); then
|
if [[ ! "${argc_init:-}" ]]; then
|
||||||
left=$((1 - "$left"))
|
left=$((1 - "$left")) # Toggle 0/1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Enforce state
|
# Enforce state
|
||||||
if (("$left")); then
|
if (("$left")); then
|
||||||
hyprctl keyword "device[$1]:left_handed" true
|
hyprctl keyword "device[${argc_device:-}]:left_handed" true
|
||||||
hyprctl keyword "device[$1]:natural_scroll" true
|
|
||||||
touch "$FILE"
|
if [[ "${argc_scroll:-}" ]]; then
|
||||||
|
hyprctl keyword "device[${argc_device:-}]:natural_scroll" true
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch "${argc_file:-}"
|
||||||
notify-send "> left" "Left-pawed" --urgency low
|
notify-send "> left" "Left-pawed" --urgency low
|
||||||
else
|
else
|
||||||
hyprctl keyword "device[$1]:left_handed" false
|
hyprctl keyword "device[${argc_device:-}]:left_handed" false
|
||||||
hyprctl keyword "device[$1]:natural_scroll" false
|
|
||||||
rm --force "$FILE"
|
if [[ "${argc_scroll:-}" ]]; then
|
||||||
|
hyprctl keyword "device[${argc_device:-}]:natural_scroll" false
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm --force "${argc_file:-}"
|
||||||
notify-send "> left" "Right-pawed" --urgency low
|
notify-send "> left" "Right-pawed" --urgency low
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue