PJ/apps/default_commands.sh
2025-06-18 09:29:04 -07:00

79 lines
1.3 KiB
Bash

### if no specific commands found run these
all(){
case $1 in
### navigation etc.
"play")
sleep .3
xdotool key space
;;
"fast_forward")
sleep .2
xdotool key Right
;;
"rewind")
sleep .2
xdotool key Left
;;
"forward" | "back" | "split_up" | "split_down")
debug "no op"
;;
"split_right")
bluetoothctl disconnect 4C:B9:9B:11:4B:31
;;
"split_left")
toggle_res
;;
### top buttons
"main" | "notification" | "settings" | "task_manager" | "search")
echo "button all_$1 is no-op"
;;
"browser")
find_or_open firefox
;;
"file_explorer")
find_or_open kodi
;;
"action_center")
find_or_open steam
;;
### arrow buttons
"desktop")
debug "no op"
;;
"tasks")
debug "no op"
;;
"sleep")
sh ~/scripts/PJ/cec.sh
;;
### test
"test")
#test code here, run with buttons.sh test
echo "sucessful test"
;;
*)
echo "button $1 not found"
;;
esac
}
toggle_res(){
display=$(xrandr --listmonitors | grep -o '\S*$' | tail -n 1)
current_res=$(xrandr | grep "$display" | grep -o '[0-9]*x[0-9]*' | head -n 1)
res_1080p="1920x1080"
res_4k="3840x2160"
if [ "$current_res" = "$res_1080p" ]; then
target_res="$res_4k"
elif [ "$current_res" = "$res_4k" ]; then
target_res="$res_1080p"
fi
debug "Switching to: $target_res"
xrandr --output "$display" --mode "$target_res"
}