fix(waybar): add hakase-popup-launch
This commit is contained in:
+52
-4
@@ -4,7 +4,54 @@
|
|||||||
myConfig,
|
myConfig,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
# --- POPUP SCRIPTS ---
|
hakase-popup-launch = pkgs.writeShellScriptBin "hakase-popup-launch" ''
|
||||||
|
tui_name=$1
|
||||||
|
active_popup=$(${pkgs.hyprland}/bin/hyprctl clients -j | ${pkgs.jq}/bin/jq -r '.[] | select(.class | startswith("org.hakase.")) | .class')
|
||||||
|
|
||||||
|
if [[ -z "''${tui_name}" ]]; then
|
||||||
|
echo "Usage: $(basename "$0") [tui-name]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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() {
|
||||||
|
exec ${pkgs.util-linux}/bin/setsid uwsm-app -- xdg-terminal-exec --app-id=org.hakase.popup."''${tui_name}" -e "''${tui_name}"
|
||||||
|
}
|
||||||
|
|
||||||
|
focus() {
|
||||||
|
exec ${pkgs.hyprland}/bin/hyprctl dispatch focuswindow "class:org.hakase.popup.''${tui_name}"
|
||||||
|
}
|
||||||
|
|
||||||
|
replace() {
|
||||||
|
${pkgs.hyprland}/bin/hyprctl dispatch closewindow "class:''${active_popup}"
|
||||||
|
sleep 1
|
||||||
|
launch
|
||||||
|
}
|
||||||
|
|
||||||
|
run() {
|
||||||
|
local status
|
||||||
|
status=$(popup_checker)
|
||||||
|
|
||||||
|
if [[ "$status" == "no_popup" ]]; then
|
||||||
|
launch
|
||||||
|
elif [[ "$status" == "same" ]]; then
|
||||||
|
focus
|
||||||
|
elif [[ "$status" == "different" ]]; then
|
||||||
|
replace
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run
|
||||||
|
'';
|
||||||
in {
|
in {
|
||||||
wayland.windowManager.hyprland.settings = {
|
wayland.windowManager.hyprland.settings = {
|
||||||
exec-once = [
|
exec-once = [
|
||||||
@@ -16,6 +63,7 @@ in {
|
|||||||
];
|
];
|
||||||
|
|
||||||
home.packages = [
|
home.packages = [
|
||||||
|
hakase-popup-launch
|
||||||
pkgs.jq
|
pkgs.jq
|
||||||
pkgs.socat
|
pkgs.socat
|
||||||
pkgs.util-linux
|
pkgs.util-linux
|
||||||
@@ -120,7 +168,7 @@ in {
|
|||||||
tooltip-format-disconnected = "Disconnected";
|
tooltip-format-disconnected = "Disconnected";
|
||||||
interval = 3;
|
interval = 3;
|
||||||
spacing = 1;
|
spacing = 1;
|
||||||
on-click = "hakase-popup-wifi";
|
on-click = "hakase-popup-launch impala";
|
||||||
};
|
};
|
||||||
|
|
||||||
"battery" = {
|
"battery" = {
|
||||||
@@ -149,12 +197,12 @@ in {
|
|||||||
format-connected = "";
|
format-connected = "";
|
||||||
format-no-controller = "";
|
format-no-controller = "";
|
||||||
tooltip-format = "Devices connected: {num_connections}";
|
tooltip-format = "Devices connected: {num_connections}";
|
||||||
on-click = "hakase-popup-bluetooth";
|
on-click = "hakase-popup-launch bluetui";
|
||||||
};
|
};
|
||||||
|
|
||||||
"pulseaudio" = {
|
"pulseaudio" = {
|
||||||
format = "{icon}";
|
format = "{icon}";
|
||||||
on-click = "hakase-popup-volume";
|
on-click = "hakase-popup-launch wiremix ";
|
||||||
on-click-right = "pamixer -t";
|
on-click-right = "pamixer -t";
|
||||||
tooltip-format = "Playing at {volume}%";
|
tooltip-format = "Playing at {volume}%";
|
||||||
scroll-step = 5;
|
scroll-step = 5;
|
||||||
|
|||||||
+34
-22
@@ -5,40 +5,52 @@ date
|
|||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
tui_name=$1
|
tui_name=$1
|
||||||
|
active_popup=$(hyprctl clients -j | jq -r '.[] | select(.class | startswith("org.hakase.")) | .class')
|
||||||
|
|
||||||
if [[ -z ${tui_name} ]]; then
|
if [[ -z ${tui_name} ]]; then
|
||||||
echo "Usage: $(basename "$0") [tui-name]"
|
echo "Usage: $(basename "$0") [tui-name]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# TODO:
|
popup_checker() {
|
||||||
# popup centered, dim-around using hypr, 70% size
|
if [[ -z "$active_popup" ]]; then
|
||||||
# objective: on-click, open corresponding application
|
echo "no_popup"
|
||||||
# must be a single-instance
|
elif [[ "$active_popup" != "org.hakase.popup.${tui_name}" ]]; then
|
||||||
# must be uwsm
|
echo "different"
|
||||||
# flow:
|
else
|
||||||
# * user clicks the icon on waybar
|
echo "same"
|
||||||
# * sh check for alive instance
|
fi
|
||||||
# * 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
|
|
||||||
|
|
||||||
launch() {
|
launch() {
|
||||||
echo "[LOG: $(date)] launching..."
|
|
||||||
}
|
|
||||||
|
|
||||||
checker() {
|
|
||||||
echo "[LOG: $(date)] checking..."
|
|
||||||
}
|
|
||||||
|
|
||||||
wrapper() {
|
|
||||||
echo "[LOG: $(date)]"
|
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() {
|
run() {
|
||||||
launch
|
local status
|
||||||
checker
|
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
|
run
|
||||||
|
|||||||
Reference in New Issue
Block a user