From 65eac681682a1acbdf0b5c7d673cf428ba79bab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Dias?= Date: Sat, 23 Nov 2024 11:58:25 -0300 Subject: [PATCH] :sparkles: add examples to rewrite window names, just like waybar --- eww/scripts/display-calendar.sh | 9 --------- eww/scripts/get-window.sh | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 10 deletions(-) delete mode 100644 eww/scripts/display-calendar.sh diff --git a/eww/scripts/display-calendar.sh b/eww/scripts/display-calendar.sh deleted file mode 100644 index e7f5eec..0000000 --- a/eww/scripts/display-calendar.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -if [[ $(eww get calendar_state) == "show" ]]; then - eww close calendar - eww update calendar_state="hidden" -else - eww open calendar - eww update calendar_state="show" -fi diff --git a/eww/scripts/get-window.sh b/eww/scripts/get-window.sh index d01e33d..bec309e 100644 --- a/eww/scripts/get-window.sh +++ b/eww/scripts/get-window.sh @@ -3,9 +3,33 @@ ACTIVE_WINDOW=$(hyprctl -j activewindow) WINDOW_TITLE=$(echo $ACTIVE_WINDOW | jq '.title' | sed -e 's/^\"//' -e 's/\"$//') WINDOW_CLASS=$(echo $ACTIVE_WINDOW | jq '.class' | sed -e 's/^\"//' -e 's/\"$//') +WINDOW_NAME="$WINDOW_CLASS: $WINDOW_TITLE" +WINDOW_CHAR_LIMIT="50" + +# Rewrite window names +case $WINDOW_CLASS in + "zen-alpha") + WINDOW_NAME="Zen Browser" + ;; + "firefox" | "org.mozilla.firefox") + WINDOW_NAME="Mozilla Firefox" + ;; +esac + +#case $WINDOW_TITLE in +# "example with window title") # case +# WINDOW_NAME="you just learned!" # statement +# ;; # breaks +#esac + +#case $WINDOW_NAME in +# "example with window name") # case +# WINDOW_NAME="something cool" # statement +# ;; # breaks +#esac if ! [[ $WINDOW_CLASS == "null" ]]; then - echo "$WINDOW_CLASS: $WINDOW_TITLE" + echo "${WINDOW_NAME:0:WINDOW_CHAR_LIMIT}" eww update widget_window_visible=true else echo ""