fix(waybar): add hakase-popup-launch
This commit is contained in:
+34
-22
@@ -5,40 +5,52 @@ date
|
||||
echo ""
|
||||
|
||||
tui_name=$1
|
||||
active_popup=$(hyprctl clients -j | jq -r '.[] | select(.class | startswith("org.hakase.")) | .class')
|
||||
|
||||
if [[ -z ${tui_name} ]]; then
|
||||
echo "Usage: $(basename "$0") [tui-name]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# TODO:
|
||||
# popup centered, dim-around using hypr, 70% size
|
||||
# objective: on-click, open corresponding application
|
||||
# must be a single-instance
|
||||
# must be uwsm
|
||||
# flow:
|
||||
# * user clicks the icon on waybar
|
||||
# * sh check for alive instance
|
||||
# * if ANY INSTANCE ALIVE and INSTANCE IS SAME, focus using hyprctl
|
||||
# * elif ANY INSTANCE ALIVE and INSTANCE IS DIFFERENT, exit the previous instance and launch the new one
|
||||
# * else launch normally
|
||||
popup_checker() {
|
||||
if [[ -z "$active_popup" ]]; then
|
||||
echo "no_popup"
|
||||
elif [[ "$active_popup" != "org.hakase.popup.${tui_name}" ]]; then
|
||||
echo "different"
|
||||
else
|
||||
echo "same"
|
||||
fi
|
||||
}
|
||||
|
||||
launch() {
|
||||
echo "[LOG: $(date)] launching..."
|
||||
}
|
||||
|
||||
checker() {
|
||||
echo "[LOG: $(date)] checking..."
|
||||
}
|
||||
|
||||
wrapper() {
|
||||
echo "[LOG: $(date)]"
|
||||
exec setsid uwsm-app -- xdg-terminal-exec --app-id=org.hakase."${tui_name}"
|
||||
exec setsid uwsm-app -- xdg-terminal-exec --app-id=org.hakase.popup."${tui_name}" -e "${tui_name}"
|
||||
}
|
||||
|
||||
focus() {
|
||||
exec hyprctl dispatch focuswindow "class:org.hakase.popup.${tui_name}"
|
||||
}
|
||||
|
||||
replace() {
|
||||
hyprctl dispatch closewindow "class:${active_popup}"
|
||||
sleep 1
|
||||
launch
|
||||
}
|
||||
|
||||
run() {
|
||||
launch
|
||||
checker
|
||||
local status
|
||||
status=$(popup_checker)
|
||||
|
||||
if [[ "$status" == "no_popup" ]]; then
|
||||
echo "[LOG: $(date)] no popup, launching..."
|
||||
launch
|
||||
elif [[ "$status" == "same" ]]; then
|
||||
echo "[LOG: $(date)] same popup, focusing..."
|
||||
focus
|
||||
elif [[ "$status" == "different" ]]; then
|
||||
echo "[LOG: $(date)] different popup, closing and relaunching..."
|
||||
replace
|
||||
fi
|
||||
}
|
||||
|
||||
run
|
||||
|
||||
Reference in New Issue
Block a user