buttons.sh latest
This commit is contained in:
commit
9aca62f78d
1 changed files with 233 additions and 0 deletions
233
buttons.sh
Normal file
233
buttons.sh
Normal file
|
@ -0,0 +1,233 @@
|
||||||
|
#!/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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
firefox_pbs(){
|
||||||
|
firefox_init
|
||||||
|
|
||||||
|
split_up(){
|
||||||
|
xdotool_helper "mouse move 500 300"
|
||||||
|
xdotool_helper "click 1 click 1"
|
||||||
|
}
|
||||||
|
play(){
|
||||||
|
xdotool_helper "mouse move 500 300"
|
||||||
|
xdotool_helper "click 1"
|
||||||
|
}
|
||||||
|
desktop(){
|
||||||
|
ff_home "https://www.pbs.org"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Kodi(){
|
||||||
|
|
||||||
|
split_up(){
|
||||||
|
xdotool_helper "key Tab"
|
||||||
|
}
|
||||||
|
search(){
|
||||||
|
kodi-send --action="VideoLibrary.Search"
|
||||||
|
}
|
||||||
|
desktop(){
|
||||||
|
kodi-send --action="PreviousMenu"
|
||||||
|
}
|
||||||
|
refresh(){
|
||||||
|
kodi-send --action="UpdateLibrary(video)"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
firefox(){
|
||||||
|
echo "return and run all()"
|
||||||
|
}
|
||||||
|
|
||||||
|
eddie(){
|
||||||
|
echo "return and run all()"
|
||||||
|
}
|
||||||
|
|
||||||
|
mousepad(){
|
||||||
|
echo "return and run all()"
|
||||||
|
}
|
||||||
|
|
||||||
|
other(){
|
||||||
|
echo "return and run all()"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### helpers
|
||||||
|
firefox_init(){
|
||||||
|
|
||||||
|
ff_home(){
|
||||||
|
xdg-open $1
|
||||||
|
sleep .3
|
||||||
|
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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue