fix: hakase scripting
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
{pkgs, ...}: {
|
{pkgs, ...}: {
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
pamixer
|
|
||||||
wiremix
|
|
||||||
impala
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
"cpu" = {
|
"cpu" = {
|
||||||
interval = 5;
|
interval = 5;
|
||||||
format = "";
|
format = "";
|
||||||
on-click = "omarchy-launch-or-focus-tui btop";
|
on-click = "omarchy-focus-wrapper btop";
|
||||||
on-click-right = "alacritty";
|
on-click-right = "alacritty";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@
|
|||||||
tooltip-format-disconnected = "Disconnected";
|
tooltip-format-disconnected = "Disconnected";
|
||||||
interval = 3;
|
interval = 3;
|
||||||
spacing = 1;
|
spacing = 1;
|
||||||
on-click = "omarchy-launch-wifi";
|
on-click = "hakase-launch-wifi";
|
||||||
};
|
};
|
||||||
|
|
||||||
"battery" = {
|
"battery" = {
|
||||||
@@ -123,12 +123,12 @@
|
|||||||
format-connected = "";
|
format-connected = "";
|
||||||
format-no-controller = "";
|
format-no-controller = "";
|
||||||
tooltip-format = "Devices connected: {num_connections}";
|
tooltip-format = "Devices connected: {num_connections}";
|
||||||
on-click = "omarchy-launch-bluetooth";
|
on-click = "hakase-launch-bluetooth";
|
||||||
};
|
};
|
||||||
|
|
||||||
"pulseaudio" = {
|
"pulseaudio" = {
|
||||||
format = "{icon}";
|
format = "{icon}";
|
||||||
on-click = "omarchy-launch-or-focus-tui wiremix";
|
on-click = "hakase-focus-wrapper 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;
|
||||||
|
|||||||
@@ -7,5 +7,6 @@
|
|||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
../../modules/system/default.nix
|
../../modules/system/default.nix
|
||||||
../../modules/system/hyprland.nix
|
../../modules/system/hyprland.nix
|
||||||
|
../../modules/system/scripts.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
../../script/hakase-lauch-or-focus-tui.nix
|
../../script/hakase-scripts.nix
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
{pkgs, ...}: let
|
|
||||||
hakase-launch-or-focus-tui = pkgs.writeShellScriptBin "omarchy-focus-wrapper" ''
|
|
||||||
# The Nix version of your script
|
|
||||||
APP_ID="org.omarchy.$(basename "$1")"
|
|
||||||
LAUNCH_COMMAND="omarchy-launch-tui $@"
|
|
||||||
|
|
||||||
exec omarchy-launch-or-focus "$APP_ID" "$LAUNCH_COMMAND"
|
|
||||||
'';
|
|
||||||
in {
|
|
||||||
environment.systemPackages = [
|
|
||||||
hakase-launch-or-focus-tui
|
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
{pkgs, ...}: let
|
||||||
|
# 1. The Brain: Logic to find a window or launch a new one
|
||||||
|
hakase-launch-or-focus = pkgs.writeShellScriptBin "hakase-launch-or-focus" ''
|
||||||
|
if (($# == 0)); then
|
||||||
|
echo "Usage: hakase-launch-or-focus [window-pattern] [launch-command]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
WINDOW_PATTERN="$1"
|
||||||
|
# Escaped Nix interpolation for shell default value logic
|
||||||
|
LAUNCH_COMMAND="''${2:-"uwsm-app -- $WINDOW_PATTERN"}"
|
||||||
|
|
||||||
|
# Locate window address via hyprctl and jq
|
||||||
|
WINDOW_ADDRESS=$(${pkgs.hyprland}/bin/hyprctl clients -j | ${pkgs.jq}/bin/jq -r --arg p "$WINDOW_PATTERN" \
|
||||||
|
'.[] | select((.class | test("\\b" + $p + "\\b"; "i")) or (.title | test("\\b" + $p + "\\b"; "i"))) | .address' | head -n1)
|
||||||
|
|
||||||
|
if [[ -n $WINDOW_ADDRESS ]]; then
|
||||||
|
# If found, focus the existing window
|
||||||
|
${pkgs.hyprland}/bin/hyprctl dispatch focuswindow "address:$WINDOW_ADDRESS"
|
||||||
|
else
|
||||||
|
# If not found, execute the launch command
|
||||||
|
eval exec setsid $LAUNCH_COMMAND
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
|
hakase-launch-tui = pkgs.writeShellScriptBin "hakase-launch-tui" ''
|
||||||
|
APP_NAME=$(basename "$1")
|
||||||
|
# Using org.hakase prefix so the focus script can find it via class name
|
||||||
|
exec setsid uwsm-app -- xdg-terminal-exec --app-id=org.hakase."$APP_NAME" -e "$@"
|
||||||
|
'';
|
||||||
|
|
||||||
|
hakase-focus-wrapper = pkgs.writeShellScriptBin "hakase-focus-wrapper" ''
|
||||||
|
APP_NAME=$(basename "$1")
|
||||||
|
WINDOW_PATTERN="org.hakase.$APP_NAME"
|
||||||
|
LAUNCH_CMD="hakase-launch-tui $*"
|
||||||
|
|
||||||
|
exec hakase-launch-or-focus "$WINDOW_PATTERN" "$LAUNCH_CMD"
|
||||||
|
'';
|
||||||
|
|
||||||
|
hakase-launch-wifi = pkgs.writeShellScriptBin "hakase-launch-wifi" ''
|
||||||
|
# Unblock the WiFi radio (requires appropriate user groups/permissions)
|
||||||
|
${pkgs.util-linux}/bin/rfkill unblock wifi
|
||||||
|
|
||||||
|
# Use the focus wrapper to launch or switch to Impala
|
||||||
|
exec hakase-focus-wrapper impala
|
||||||
|
'';
|
||||||
|
|
||||||
|
hakase-launch-bluetooth =
|
||||||
|
pkgs.writeShellScriptBin "hakase-launch-bluetooth"
|
||||||
|
''
|
||||||
|
${pkgs.util-linux}/bin/rfkill unblock wifi
|
||||||
|
exec hakase-focus-wrapper bluetui
|
||||||
|
'';
|
||||||
|
in {
|
||||||
|
environment.systemPackages = [
|
||||||
|
pkgs.jq
|
||||||
|
pkgs.util-linux # Provides rfkill
|
||||||
|
pkgs.bluetui
|
||||||
|
pkgs.impala
|
||||||
|
pkgs.wiremix
|
||||||
|
pkgs.pamixer
|
||||||
|
hakase-launch-or-focus
|
||||||
|
hakase-launch-tui
|
||||||
|
hakase-focus-wrapper
|
||||||
|
hakase-launch-wifi
|
||||||
|
hakase-launch-bluetooth
|
||||||
|
];
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user