2024-03-26 20:03:07 -07:00
|
|
|
#!/bin/bash
|
|
|
|
shopt -s nocasematch #sets case insensitive option for the shell
|
|
|
|
websites=("youtube" "pbs")
|
|
|
|
|
|
|
|
|
|
|
|
### if no specific commands found run these
|
|
|
|
all(){
|
|
|
|
case $1 in
|
|
|
|
### navigation etc.
|
|
|
|
"play")
|
|
|
|
#sleep .5
|
|
|
|
xdotool_helper "key space"
|
|
|
|
;;
|
|
|
|
"fast_forward")
|
|
|
|
xdotool_helper "key Right"
|
|
|
|
;;
|
|
|
|
"rewind")
|
|
|
|
xdotool_helper "key Left"
|
|
|
|
;;
|
|
|
|
"forward" | "back" | "split_up" | "split_down")
|
|
|
|
sleep .1
|
|
|
|
echo "no default action assigned to $1"
|
|
|
|
;;
|
|
|
|
"split_right")
|
|
|
|
bluetoothctl disconnect 4C:B9:9B:11:4B:31
|
|
|
|
;;
|
|
|
|
"split_left")
|
|
|
|
sh /home/htpc/scripts/xrandr.sh
|
|
|
|
;;
|
|
|
|
|
|
|
|
### top buttons
|
|
|
|
"main" | "notification" | "settings" | "task_manager" | "search")
|
|
|
|
echo "no default action assigned to $1"
|
|
|
|
;;
|
|
|
|
"browser")
|
|
|
|
helper_find_or_open firefox
|
|
|
|
;;
|
|
|
|
"file_explorer")
|
|
|
|
helper_find_or_open kodi
|
|
|
|
;;
|
|
|
|
"action_center")
|
|
|
|
helper_find_or_open steam
|
|
|
|
;;
|
|
|
|
|
|
|
|
### arrow buttons
|
|
|
|
"desktop")
|
|
|
|
;;
|
|
|
|
"tasks")
|
|
|
|
;;
|
|
|
|
|
|
|
|
### test
|
|
|
|
"test")
|
|
|
|
#test code here, run with buttons.sh test
|
|
|
|
echo "sucessful test"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "unexpected action: ${1-}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
firefox_youtube(){
|
|
|
|
firefox_init
|
|
|
|
|
|
|
|
split_up(){
|
|
|
|
|
|
|
|
xdotool_helper "key f"
|
|
|
|
}
|
|
|
|
search(){
|
|
|
|
ff_search
|
|
|
|
}
|
|
|
|
play(){
|
|
|
|
echo "ffyt play"
|
|
|
|
xdotool_helper "key k"
|
|
|
|
}
|
|
|
|
desktop(){
|
|
|
|
ff_home "https://www.youtube.com"
|
|
|
|
}
|
|
|
|
split_right(){
|
|
|
|
xdotool_helper "key F11"
|
|
|
|
}
|
2024-05-27 17:22:40 -07:00
|
|
|
move_up(){
|
|
|
|
ff_home 'ext+container:name=shared&url=https://youtube.com'
|
|
|
|
}
|
|
|
|
back(){
|
|
|
|
ff_home 'ext+container:name=hh&url=https://youtube.com'
|
|
|
|
}
|
|
|
|
forward(){
|
|
|
|
ff_home 'ext+container:name=fr&url=https://youtube.com'
|
|
|
|
}
|
2024-03-26 20:03:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
firefox_pbs(){
|
|
|
|
firefox_init
|
|
|
|
|
|
|
|
split_up(){
|
2024-04-01 19:41:17 -07:00
|
|
|
xdotool_helper "mousemove 500 300"
|
2024-03-26 20:03:07 -07:00
|
|
|
xdotool_helper "click 1 click 1"
|
|
|
|
}
|
|
|
|
play(){
|
2024-04-01 19:41:17 -07:00
|
|
|
xdotool_helper "mousemove 500 300"
|
2024-03-26 20:03:07 -07:00
|
|
|
xdotool_helper "click 1"
|
|
|
|
}
|
|
|
|
desktop(){
|
|
|
|
ff_home "https://www.pbs.org"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Kodi(){
|
|
|
|
|
2024-04-01 20:27:47 -07:00
|
|
|
play(){
|
|
|
|
kodi-send --action="PlayPause"
|
|
|
|
}
|
2024-04-14 20:24:41 -07:00
|
|
|
forward(){
|
|
|
|
kodi-send --action="SkipNext"
|
|
|
|
}
|
|
|
|
back(){
|
|
|
|
kodi-send --action="SkipPrevious"
|
|
|
|
}
|
2024-03-26 20:03:07 -07:00
|
|
|
split_up(){
|
2024-03-31 16:45:06 -07:00
|
|
|
xdotool_helper "key p"
|
2024-03-26 20:03:07 -07:00
|
|
|
}
|
2024-04-16 20:35:57 -07:00
|
|
|
move_up(){
|
|
|
|
xdotool_helper "key o"
|
|
|
|
}
|
2024-03-26 20:03:07 -07:00
|
|
|
search(){
|
|
|
|
kodi-send --action="VideoLibrary.Search"
|
|
|
|
}
|
|
|
|
desktop(){
|
|
|
|
kodi-send --action="PreviousMenu"
|
|
|
|
}
|
|
|
|
refresh(){
|
|
|
|
kodi-send --action="UpdateLibrary(video)"
|
|
|
|
}
|
2024-04-01 20:27:47 -07:00
|
|
|
notification(){
|
|
|
|
kodi-send --action="ShowSubtitles"
|
|
|
|
}
|
|
|
|
settings(){
|
2024-04-01 20:46:59 -07:00
|
|
|
kodi-send --action="ActivateWindow(10123)"
|
|
|
|
for i in {0..3}
|
|
|
|
do
|
|
|
|
kodi-send --action="Down"
|
|
|
|
done
|
|
|
|
kodi-send --action="Select"
|
2024-04-01 20:27:47 -07:00
|
|
|
}
|
2024-04-28 16:26:03 -07:00
|
|
|
fast_forward(){
|
|
|
|
kodi-send --action="NextPreset"
|
|
|
|
}
|
|
|
|
rewind(){
|
|
|
|
kodi-send --action="PreviousPreset"
|
|
|
|
}
|
|
|
|
split_right(){
|
|
|
|
kodi-send --action="LockPreset"
|
|
|
|
}
|
2024-03-26 20:03:07 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
steam_bp(){
|
|
|
|
|
|
|
|
desktop(){
|
|
|
|
xdotool_helper "key alt+Enter"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
steam_lp(){
|
|
|
|
|
|
|
|
desktop(){
|
|
|
|
xdotool_helper "mousemove 1872 13"
|
|
|
|
xdotool_helper "click 1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Xfdesktop(){
|
|
|
|
|
|
|
|
search(){
|
|
|
|
rofi -modi drun,run -show drun
|
|
|
|
}
|
|
|
|
next(){
|
|
|
|
xfdesktop -N
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-22 20:26:19 -07:00
|
|
|
Spotify(){
|
|
|
|
play(){
|
|
|
|
xdotool_helper "key space"
|
|
|
|
}
|
|
|
|
forward(){
|
|
|
|
xdotool_helper "key XF86AudioNext"
|
|
|
|
}
|
|
|
|
back(){
|
|
|
|
xdotool_helper "key XF86AudioPrev"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-27 17:22:40 -07:00
|
|
|
#firefox(){
|
2024-04-21 16:43:39 -07:00
|
|
|
|
2024-05-27 17:22:40 -07:00
|
|
|
# echo "return and run all()"
|
|
|
|
#}
|
2024-03-26 20:03:07 -07:00
|
|
|
|
2024-04-21 16:43:39 -07:00
|
|
|
discord(){
|
|
|
|
|
|
|
|
play(){
|
|
|
|
xdotool_helper "key F12"
|
|
|
|
}
|
2024-03-26 20:03:07 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
mousepad(){
|
|
|
|
echo "return and run all()"
|
|
|
|
}
|
|
|
|
|
|
|
|
other(){
|
|
|
|
echo "return and run all()"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### helpers
|
|
|
|
firefox_init(){
|
|
|
|
|
|
|
|
ff_home(){
|
2024-05-27 17:22:40 -07:00
|
|
|
#xdg-open $1
|
|
|
|
firefox $1
|
2024-03-31 20:18:43 -07:00
|
|
|
sleep .1
|
2024-03-26 20:03:07 -07:00
|
|
|
xdotool_helper "key ctrl+shift+Tab"
|
|
|
|
sleep .1
|
|
|
|
xdotool_helper "key ctrl+w"
|
|
|
|
|
|
|
|
}
|
|
|
|
ff_search(){
|
|
|
|
sleep .2
|
|
|
|
xdotool_helper "key slash"
|
|
|
|
sleep .2
|
|
|
|
xdotool_helper "key ctrl+a"
|
|
|
|
sleep .2
|
|
|
|
xdotool_helper "key BackSpace"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
helper_find_or_open() {
|
|
|
|
windows=$(wmctrl -l)
|
|
|
|
if [[ "$windows" == *"$1"* ]]; then
|
|
|
|
xdotool windowactivate "$(wmctrl -l | grep -i "$1" | cut -d " " -f 1)"
|
|
|
|
else
|
|
|
|
nohup "$1" >/dev/null 2>&1 &
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
xdotool_helper(){
|
|
|
|
sleep .2
|
|
|
|
xdotool $1
|
|
|
|
}
|
|
|
|
|
|
|
|
### get active window
|
|
|
|
target="$(xdotool getactivewindow getwindowclassname)"
|
|
|
|
|
|
|
|
if [[ "$target" == *"firefox"* ]]; then
|
|
|
|
name="$(xdotool getactivewindow getwindowname)"
|
|
|
|
for ws in "${websites[@]}"; do
|
|
|
|
if [[ "$name" == *"$ws"* ]]; then
|
|
|
|
target+="_$ws"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
elif [[ "$target" == *"steam"* ]]; then
|
|
|
|
name="$(xdotool getactivewindow getwindowname)"
|
|
|
|
if [[ "$name" == *"picture"* ]]; then
|
|
|
|
target+="_bp"
|
|
|
|
else
|
|
|
|
tagret+="_lp"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
printf "action: %s\ntarget: %s\n" "$1" "$target"
|
|
|
|
|
|
|
|
### init target functions
|
|
|
|
$target
|
|
|
|
|
|
|
|
### find and run $1
|
|
|
|
if [[ $(type -t $1) == function ]]; then
|
|
|
|
$1
|
|
|
|
else
|
|
|
|
echo "program specific method not found calling all_$1"
|
|
|
|
all $1
|
|
|
|
#echo "unexpected action: ${1-}"
|
|
|
|
fi
|
|
|
|
|