allow running find_or_open as standalone

This commit is contained in:
zerf58 2025-06-18 09:27:25 -07:00
parent 847ecd0214
commit fa119a8d4f
3 changed files with 14 additions and 8 deletions

View file

@ -27,16 +27,16 @@ all(){
### top buttons ### top buttons
"main" | "notification" | "settings" | "task_manager" | "search") "main" | "notification" | "settings" | "task_manager" | "search")
echo "no default action assigned to $1" echo "button all_$1 is no-op"
;; ;;
"browser") "browser")
helper_find_or_open firefox find_or_open firefox
;; ;;
"file_explorer") "file_explorer")
helper_find_or_open kodi find_or_open kodi
;; ;;
"action_center") "action_center")
helper_find_or_open steam find_or_open steam
;; ;;
### arrow buttons ### arrow buttons
@ -56,7 +56,7 @@ all(){
echo "sucessful test" echo "sucessful test"
;; ;;
*) *)
echo "unexpected action: ${1-}" echo "button $1 not found"
;; ;;
esac esac

View file

@ -10,10 +10,12 @@ kodi(){
kodi-send --action="SkipPrevious" kodi-send --action="SkipPrevious"
} }
split_up(){ split_up(){
xdotool_helper "key p" sleep .2
xdotool key p
} }
move_up(){ move_up(){
xdotool_helper "key o" sleep .2
xdotool key o
} }
search(){ search(){
kodi-send --action="VideoLibrary.Search" kodi-send --action="VideoLibrary.Search"

View file

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
helper_find_or_open(){ find_or_open(){
windows=$(wmctrl -l) windows=$(wmctrl -l)
if [[ "${windows,,}" == *"$1"* ]]; then if [[ "${windows,,}" == *"$1"* ]]; then
xdotool windowactivate "$(wmctrl -l | grep -i "$1" | cut -d " " -f 1)" xdotool windowactivate "$(wmctrl -l | grep -i "$1" | cut -d " " -f 1)"
@ -9,3 +9,7 @@ helper_find_or_open(){
echo "opening $1" echo "opening $1"
fi fi
} }
if [[ ! -z $1 ]]; then
find_or_open $1
fi