From 97cfa63fc5e212ce60326c42f1d44a843a5ed179 Mon Sep 17 00:00:00 2001 From: Stephan Raabe Date: Tue, 26 Dec 2023 10:56:06 +0100 Subject: [PATCH] Add systray --- CHANGELOG | 1 + .../modules/waybar/bluetooth/config.sh | 2 +- .../modules/waybar/bluetooth/module.sh | 2 +- .../settings/modules/waybar/systray/config.sh | 2 + .../settings/modules/waybar/systray/module.sh | 50 +++++++++++++++++++ waybar/modules.json | 2 +- waybar/themes/ml4w-blur-bottom/config | 3 ++ waybar/themes/ml4w-blur/config | 3 ++ waybar/themes/ml4w-blur/style.css | 3 +- waybar/themes/ml4w-bottom/config | 3 ++ waybar/themes/ml4w/config | 3 ++ waybar/themes/ml4w/style.css | 3 +- 12 files changed, 70 insertions(+), 7 deletions(-) create mode 100644 hypr/settings/modules/waybar/systray/config.sh create mode 100755 hypr/settings/modules/waybar/systray/module.sh diff --git a/CHANGELOG b/CHANGELOG index 8d57ba9..d5ec6cb 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -15,6 +15,7 @@ Hyprland: - Wallpaper selector now with preview thumbnails - Settings script reworked completely. Implementation of custom modules are now possible. - Waybar settings module to edit some ML4W waybar themes settings on the fly +- Waybar with Systray (can be hidden in settings script) - SDDM settings module to update the SDDM background with current wallpaper - All image formats are now supported for setting a wallpaper (jpg,jpeg,png,...) diff --git a/hypr/settings/modules/waybar/bluetooth/config.sh b/hypr/settings/modules/waybar/bluetooth/config.sh index c130399..615fc47 100644 --- a/hypr/settings/modules/waybar/bluetooth/config.sh +++ b/hypr/settings/modules/waybar/bluetooth/config.sh @@ -1,2 +1,2 @@ -name="Hide Bluetooth" +name="Toggle Bluetooth" order=1 diff --git a/hypr/settings/modules/waybar/bluetooth/module.sh b/hypr/settings/modules/waybar/bluetooth/module.sh index 88246b7..687d1c9 100755 --- a/hypr/settings/modules/waybar/bluetooth/module.sh +++ b/hypr/settings/modules/waybar/bluetooth/module.sh @@ -1,7 +1,7 @@ #!/bin/bash _getHeader "$name" "$author" -echo "Hide the bluetooth icon in ML4W waybar themes." +echo "Hide or show the bluetooth icon in ML4W waybar themes." # Define File targetFile1="$HOME/dotfiles/waybar/themes/ml4w/config" diff --git a/hypr/settings/modules/waybar/systray/config.sh b/hypr/settings/modules/waybar/systray/config.sh new file mode 100644 index 0000000..913073e --- /dev/null +++ b/hypr/settings/modules/waybar/systray/config.sh @@ -0,0 +1,2 @@ +name="Toggle Systray" +order=1 diff --git a/hypr/settings/modules/waybar/systray/module.sh b/hypr/settings/modules/waybar/systray/module.sh new file mode 100755 index 0000000..927f650 --- /dev/null +++ b/hypr/settings/modules/waybar/systray/module.sh @@ -0,0 +1,50 @@ +#!/bin/bash +_getHeader "$name" "$author" + +echo "Hide or Show the systray in ML4W waybar themes." + +# Define File +targetFile1="$HOME/dotfiles/waybar/themes/ml4w/config" +targetFile2="$HOME/dotfiles/waybar/themes/ml4w-blur/config" +targetFile3="$HOME/dotfiles/waybar/themes/ml4w-blur-bottom/config" +targetFile4="$HOME/dotfiles/waybar/themes/ml4w-bottom/config" + +if [ ! -f $targetFile1 ] || [ ! -f $targetFile2 ] || [ ! -f $targetFile3 ] || [ ! -f $targetFile4 ] ;then + echo "ERROR: Target file not found." + sleep 2 + _goBack +fi + +# Define Markers +startMarker="\/\/ START TRAY TOOGLE" +endMarker="\/\/ END TRAY TOOGLE" + +# Define Replacement Template +customtemplate="VALUE\"tray\"," + +# Select Value +customvalue=$(gum choose "SHOW" "HIDE") + +if [ ! -z $customvalue ]; then + if [ "$customvalue" == "SHOW" ] ;then + customvalue="" + else + customvalue="//" + fi + + # Replace in Template + customtext="${customtemplate/VALUE/"$customvalue"}" + + _replaceInFile $startMarker $endMarker $customtext $targetFile1 + _replaceInFile $startMarker $endMarker $customtext $targetFile2 + _replaceInFile $startMarker $endMarker $customtext $targetFile3 + _replaceInFile $startMarker $endMarker $customtext $targetFile4 + + # Reload Waybar + setsid $HOME/dotfiles/waybar/launch.sh 1>/dev/null 2>&1 & + _goBack +else + echo "ERROR: Define a value." + sleep 2 + _goBack +fi diff --git a/waybar/modules.json b/waybar/modules.json index 3c15275..6ddc6b5 100644 --- a/waybar/modules.json +++ b/waybar/modules.json @@ -197,7 +197,7 @@ // System tray "tray": { - // "icon-size": 21, + "icon-size": 21, "spacing": 10 }, diff --git a/waybar/themes/ml4w-blur-bottom/config b/waybar/themes/ml4w-blur-bottom/config index f82d591..b55b111 100644 --- a/waybar/themes/ml4w-blur-bottom/config +++ b/waybar/themes/ml4w-blur-bottom/config @@ -58,6 +58,9 @@ "group/settings", "custom/cliphist", "idle_inhibitor", + // START TRAY TOOGLE + "tray", + // END TRAY TOOGLE "custom/exit", "clock" ] diff --git a/waybar/themes/ml4w-blur/config b/waybar/themes/ml4w-blur/config index 608f028..f4b13ae 100644 --- a/waybar/themes/ml4w-blur/config +++ b/waybar/themes/ml4w-blur/config @@ -57,6 +57,9 @@ "group/hardware", "custom/cliphist", "idle_inhibitor", + // START TRAY TOOGLE + "tray", + // END TRAY TOOGLE "custom/exit", "clock" ] diff --git a/waybar/themes/ml4w-blur/style.css b/waybar/themes/ml4w-blur/style.css index 6d42c2a..dede8df 100644 --- a/waybar/themes/ml4w-blur/style.css +++ b/waybar/themes/ml4w-blur/style.css @@ -407,7 +407,7 @@ window#waybar.empty #window { * ----------------------------------------------------- */ #tray { - background-color: #2980b9; + padding: 0px 15px 0px 0px; } #tray > .passive { @@ -416,7 +416,6 @@ window#waybar.empty #window { #tray > .needs-attention { -gtk-icon-effect: highlight; - background-color: #eb4d4b; } /* ----------------------------------------------------- diff --git a/waybar/themes/ml4w-bottom/config b/waybar/themes/ml4w-bottom/config index 0dbdb34..fd791e2 100644 --- a/waybar/themes/ml4w-bottom/config +++ b/waybar/themes/ml4w-bottom/config @@ -57,6 +57,9 @@ "group/hardware", "custom/cliphist", "idle_inhibitor", + // START TRAY TOOGLE + "tray", + // END TRAY TOOGLE "custom/exit", "clock" ] diff --git a/waybar/themes/ml4w/config b/waybar/themes/ml4w/config index 1813329..c02c13f 100644 --- a/waybar/themes/ml4w/config +++ b/waybar/themes/ml4w/config @@ -57,6 +57,9 @@ "group/hardware", "custom/cliphist", "idle_inhibitor", + // START TRAY TOOGLE + "tray", + // END TRAY TOOGLE "custom/exit", "clock" ] diff --git a/waybar/themes/ml4w/style.css b/waybar/themes/ml4w/style.css index 1bc1cda..475b52f 100644 --- a/waybar/themes/ml4w/style.css +++ b/waybar/themes/ml4w/style.css @@ -408,7 +408,7 @@ window#waybar.empty #window { * ----------------------------------------------------- */ #tray { - background-color: #2980b9; + padding: 0px 15px 0px 0px; } #tray > .passive { @@ -417,7 +417,6 @@ window#waybar.empty #window { #tray > .needs-attention { -gtk-icon-effect: highlight; - background-color: #eb4d4b; } /* -----------------------------------------------------