From 37162cbab61134841dd87de0ddd5d22fd462cf98 Mon Sep 17 00:00:00 2001 From: Stephan Raabe Date: Mon, 18 Dec 2023 21:57:32 +0100 Subject: [PATCH] Updates --- .../modules/waybar/appslabel/module.sh | 1 - .../modules/waybar/bluetooth/config.sh | 2 + .../modules/waybar/bluetooth/module.sh | 58 +++++++++++++++++++ hypr/settings/modules/waybar/date/module.sh | 1 - .../modules/waybar/workspaces/module.sh | 1 - waybar/launch.sh | 5 ++ waybar/themes/ml4w/config | 2 + 7 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 hypr/settings/modules/waybar/bluetooth/config.sh create mode 100755 hypr/settings/modules/waybar/bluetooth/module.sh diff --git a/hypr/settings/modules/waybar/appslabel/module.sh b/hypr/settings/modules/waybar/appslabel/module.sh index 346857d..ad3505a 100755 --- a/hypr/settings/modules/waybar/appslabel/module.sh +++ b/hypr/settings/modules/waybar/appslabel/module.sh @@ -22,7 +22,6 @@ if [ ! -z $customvalue ]; then # Ensure that markers are in target file if grep -s "$startMarker" $targetFile && grep -s "$endMarker" $targetFile; then - echo "Exists" # Write into File sed -i '/'"$startMarker"'/,/'"$endMarker"'/ { diff --git a/hypr/settings/modules/waybar/bluetooth/config.sh b/hypr/settings/modules/waybar/bluetooth/config.sh new file mode 100644 index 0000000..7eec010 --- /dev/null +++ b/hypr/settings/modules/waybar/bluetooth/config.sh @@ -0,0 +1,2 @@ +name="Bluetooth" +order=1 diff --git a/hypr/settings/modules/waybar/bluetooth/module.sh b/hypr/settings/modules/waybar/bluetooth/module.sh new file mode 100755 index 0000000..314bd8e --- /dev/null +++ b/hypr/settings/modules/waybar/bluetooth/module.sh @@ -0,0 +1,58 @@ +#!/bin/bash +_getHeader "$name" "$author" + +echo "Hide the bluetooth icon in waybar." + +# Define File +targetFile="$HOME/dotfiles/waybar/themes/ml4w/config" + +if [ ! -f $targetFile ] ;then + echo "ERROR: Target file not found." + sleep 2 + _goBack +fi + +# Define Markers +startMarker="\/\/ START BT TOOGLE" +endMarker="\/\/ END BT TOOGLE" + +# Define Replacement Template +customtemplate="VALUE\"bluetooth\"," + +# 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"}" + + # Ensure that markers are in target file + if grep -s "$startMarker" $targetFile && grep -s "$endMarker" $targetFile; then + + # Write into File + sed -i '/'"$startMarker"'/,/'"$endMarker"'/ { + //!d + /'"$startMarker"'/a\ + '"$customtext"' + }' $targetFile + + # Reload Waybar + $HOME/dotfiles/waybar/launch.sh 1>/dev/null 2>&1 + _goBack + + else + echo "ERROR: Marker not found." + sleep 2 + _goBack + fi +else + echo "ERROR: Define a value." + sleep 2 + _goBack +fi diff --git a/hypr/settings/modules/waybar/date/module.sh b/hypr/settings/modules/waybar/date/module.sh index 7dce111..93cc5fd 100755 --- a/hypr/settings/modules/waybar/date/module.sh +++ b/hypr/settings/modules/waybar/date/module.sh @@ -21,7 +21,6 @@ if [ ! -z $customvalue ]; then # Ensure that markers are in target file if grep -s "$startMarker" $targetFile && grep -s "$endMarker" $targetFile; then - echo "Exists" # Write into File sed -i '/'"$startMarker"'/,/'"$endMarker"'/ { diff --git a/hypr/settings/modules/waybar/workspaces/module.sh b/hypr/settings/modules/waybar/workspaces/module.sh index 5129bb1..3883465 100755 --- a/hypr/settings/modules/waybar/workspaces/module.sh +++ b/hypr/settings/modules/waybar/workspaces/module.sh @@ -19,7 +19,6 @@ customtext="${customtemplate/VALUE/"$customvalue"}" # Ensure that markers are in target file if grep -s "$startMarker" $targetFile && grep -s "$endMarker" $targetFile; then - echo "Exists" # Write into File sed -i '/'"$startMarker"'/,/'"$endMarker"'/ { diff --git a/waybar/launch.sh b/waybar/launch.sh index cfec025..385097b 100755 --- a/waybar/launch.sh +++ b/waybar/launch.sh @@ -48,4 +48,9 @@ fi if [ -f ~/dotfiles/waybar/themes${arrThemes[1]}/style-custom.css ] ;then style_file="style-custom.css" fi + +# Check used files +echo "Config: $config_file" +echo "Style: $style_file" + waybar -c ~/dotfiles/waybar/themes${arrThemes[0]}/$config_file -s ~/dotfiles/waybar/themes${arrThemes[1]}/$style_file & diff --git a/waybar/themes/ml4w/config b/waybar/themes/ml4w/config index 55c1a15..1813329 100644 --- a/waybar/themes/ml4w/config +++ b/waybar/themes/ml4w/config @@ -49,7 +49,9 @@ "modules-right": [ "custom/updates", "pulseaudio", + // START BT TOOGLE "bluetooth", + // END BT TOOGLE "battery", "network", "group/hardware",