feat: Adds waybarctl to combine scripts that were similar.

This commit is contained in:
2025-10-04 19:08:29 -04:00
parent 33e6683369
commit bad3282dc5
5 changed files with 74 additions and 30 deletions

View File

@@ -56,11 +56,11 @@ bindd = $mainMod, K, Focus window - up, movefo
bindd = $mainMod, L, Focus window - right, movefocus, r # move window focus using vim keys
bindd = $mainMod SHIFT, L, Workspace - forward, workspace, +1
bindd = $mainMod, M, [M]usic - apple, exec, $pwa --special music "https://music.apple.com"
bindd = $mainMod SHIFT, M, [M]enu bar - toggle visible, exec, $scripts/toggle-waybar
bindd = $mainMod SHIFT, M, [M]enu bar - toggle visible, exec, $scripts/waybarctl --toggle
bindd = $mainMod, O, Purchase [o]rders, exec, $pwa --special dispatch "https://po.housh.dev"
bindd = $mainMod, P, [P]assword manager, exec, $pwa --special pass "https://pass.proton.me"
bindd = $mainMod SHIFT, P, Toggle [p]seudo window mode, pseudo, # dwindle
bindd = $mainMod SHIFT, R, [R]estart menu bar, exec, $scripts/waybar-restart
bindd = $mainMod SHIFT, R, [R]estart menu bar, exec, $scripts/waybarctl --restart
bindd = $mainMod, S, Toggle [s]pecial workspace, togglespecialworkspace, magic # use $windowMod S to send window to the special workspace
bindd = $mainMod, Y, [Y]ouTube, exec, $pwa --or-focus "https://youtube.com"
bindd = $mainMod, U, [U]nifi, exec, $pwa "https://unifi.ui.com"

View File

@@ -1,34 +1,34 @@
[
{
"name": "Install Web App",
"name": "App - install web app",
"exec": "$SCRIPTS/hypr/install-webapp"
},
{
"name": "Uninstall Desktop App",
"name": "App - uninstall desktop app",
"exec": "$SCRIPTS/hypr/uninstall-desktop-app"
},
{
"name": "Active Window Table / Picker",
"exec": "$SCRIPTS/hypr/window-table"
},
{
"name": "Clear Clipboard History",
"name": "Clipboard - clear history",
"exec": "$SCRIPTS/hypr/clear-clipboard-history && echo Done"
},
{
"name": "Restart waybar",
"exec": "$SCRIPTS/hypr/waybar-restart"
"name": "Waybar - restart",
"exec": "$SCRIPTS/hypr/waybarctl --restart"
},
{
"name": "Toggle waybar",
"exec": "$SCRIPTS/hypr/toggle-waybar"
"name": "Waybar -- toggle",
"exec": "$SCRIPTS/hypr/waybarctl --toggle"
},
{
"name": "Close Windows - Active Workspace",
"name": "Windows - active window table / picker",
"exec": "$SCRIPTS/hypr/window-table"
},
{
"name": "Windows - close ALL in active workspace",
"exec": "$SCRIPTS/hypr/close-windows --active-workspace"
},
{
"name": "Close Windows - ALL",
"name": "Windows - close ALL in all workspaces",
"exec": "$SCRIPTS/hypr/close-windows --all"
}
]

View File

@@ -1,11 +0,0 @@
#!/bin/sh
WAYBAR_PID=$(pgrep -x waybar)
if [ -n "$WAYBAR_PID" ]; then
# kill waybar process if it's running.
kill "$WAYBAR_PID"
else
# start waybar in the background.
setsid uwsm app -- waybar >/dev/null 2>&1 &
fi

View File

@@ -1,4 +0,0 @@
#!/bin/zsh
pkill -x waybar
setsid uwsm app -- waybar >/dev/null 2>&1 &

59
env/.local/scripts/hypr/waybarctl vendored Executable file
View File

@@ -0,0 +1,59 @@
#!/usr/bin/env bash
THIS=$(basename ${BASH_SOURCE[0]})
usage() {
cat <<EOF
Waybar control manager.
USAGE:
$ $THIS [OPTION]
OPTIONS:
-k | --kill: Kill waybar
-r | --restart: Restart waybar.
-s | --start: Start waybar.
-t | --toggle: Toggle visibility of waybar.
-h | --help: Show this help page.
EOF
}
kill_flag="0"
restart_flag="0"
start_flag="0"
toggle_flag="0"
waybar_pid=$(pgrep -x waybar)
while [[ $# -gt 0 ]]; do
if [[ $1 == "-k" ]] || [[ $1 == "--kill" ]]; then
kill_flag="1"
elif [[ $1 == "-r" ]] || [[ $1 == "--restart" ]]; then
restart_flag="1"
elif [[ $1 == "-s" ]] || [[ $1 == "--start" ]]; then
start_flag="1"
elif [[ $1 == "-t" ]] || [[ $1 == "--toggle" ]]; then
toggle_flag="1"
elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
usage && exit 0
fi
shift
done
# Handle flags & state that need to kill the waybar process.
if [[ $kill_flag == "1" ]] ||
[[ $restart_flag == "1" ]] ||
([[ $toggle_flag == "1" ]] && [[ -n $waybar_pid ]]); then
pkill -x waybar
fi
# Handle flags & state that need to start the waybar process.
if [[ $restart_flag == "1" ]] ||
([[ $start_flag == "1" ]] && [[ -z $waybar_pid ]]) ||
([[ $toggle_flag == "1" ]] && [[ -z $waybar_pid ]]); then
setsid uwsm app -- waybar >/dev/null 2>&1 &
sleep 1 # Sleep to allow it to start if running in a pop up terminal.
fi