From 46e60f530d052a74f87e92b9b4a442e36167833a Mon Sep 17 00:00:00 2001 From: Jeena Date: Wed, 17 Dec 2025 11:47:24 +0900 Subject: [PATCH] Add possibility to have host specific menu lines in tofi For the Shift+SUPER custom menu I wanted to be able to add some copy and paste things which I don't want to have everywhere especially not uploaded and stored in git. Now it's possible to have a aditional menu-{hostname}.list where you can put extra things for this specific host. I added there things like: Phone=echo "012345678" | wl-copy because I often need this specific phone number and don't want to need to start the Contacts app and search for the number and copy it. I'm planning to add more host specific things. --- .gitignore | 1 + hypr/scripts/launch-menu.sh | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b5668e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +hypr/menu-*.list diff --git a/hypr/scripts/launch-menu.sh b/hypr/scripts/launch-menu.sh index 8c21518..d32c9a4 100755 --- a/hypr/scripts/launch-menu.sh +++ b/hypr/scripts/launch-menu.sh @@ -1,13 +1,22 @@ #!/usr/bin/env bash -SCRIPTS="$HOME/.config/hypr/menu.list" +BASE_MENU="$HOME/.config/hypr/menu.list" +HOST_MENU="$HOME/.config/hypr/menu-$(hostname).list" HISTORY_FILE="$HOME/.cache/tofi/launch-menu.txt" -# Kill existing tofi instance if running +# Build effective menu (host-specific overrides public) +MENU_CONTENT=$(cat "$BASE_MENU" 2>/dev/null) +[ -f "$HOST_MENU" ] && MENU_CONTENT=$(cat "$BASE_MENU" "$HOST_MENU") + pkill -x tofi || { - chosen=$(cut -d'=' -f1 "$SCRIPTS" | tofi --history-file="$HISTORY_FILE" --history=true --require-match=true --fuzzy-match=true) + chosen=$(printf '%s\n' "$MENU_CONTENT" \ + | cut -d'=' -f1 \ + | tofi --history-file="$HISTORY_FILE" --history=true --require-match=true --fuzzy-match=true) + if [ -n "$chosen" ]; then - script=$(awk -F= -v sel="$chosen" '$1==sel {print $2}' "$SCRIPTS") + script=$(printf '%s\n' "$MENU_CONTENT" \ + | awk -F= -v sel="$chosen" '$1==sel {print $2}' \ + | tail -n1) [ -n "$script" ] && eval "$script" & fi }