add examples to rewrite window names, just like waybar

This commit is contained in:
João Dias
2024-11-23 11:58:25 -03:00
parent cbbd43c4f2
commit 65eac68168
2 changed files with 25 additions and 10 deletions
-9
View File
@@ -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
+25 -1
View File
@@ -3,9 +3,33 @@
ACTIVE_WINDOW=$(hyprctl -j activewindow) ACTIVE_WINDOW=$(hyprctl -j activewindow)
WINDOW_TITLE=$(echo $ACTIVE_WINDOW | jq '.title' | sed -e 's/^\"//' -e 's/\"$//') 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_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 if ! [[ $WINDOW_CLASS == "null" ]]; then
echo "$WINDOW_CLASS: $WINDOW_TITLE" echo "${WINDOW_NAME:0:WINDOW_CHAR_LIMIT}"
eww update widget_window_visible=true eww update widget_window_visible=true
else else
echo "" echo ""