From c0bb760662f9ffab55308502f3e1595b2d973c32 Mon Sep 17 00:00:00 2001 From: q3aql Date: Sun, 3 Aug 2025 20:31:50 +0200 Subject: [PATCH] .config/waybar --- .config/waybar/config | 8 +++++++- .config/waybar/scripts/cpu_info.sh | 6 +++--- .config/waybar/scripts/current_date.sh | 2 +- .config/waybar/scripts/get_lang.sh | 14 ++++++++++++++ .config/waybar/style.css | 6 ++++++ 5 files changed, 31 insertions(+), 5 deletions(-) create mode 100755 .config/waybar/scripts/get_lang.sh diff --git a/.config/waybar/config b/.config/waybar/config index 9f7d756..800b19b 100644 --- a/.config/waybar/config +++ b/.config/waybar/config @@ -2,7 +2,7 @@ "position": "top", // Waybar position (top|bottom|left|right) "height": 28, // Waybar height (to be removed for auto height) "modules-left": ["custom/desktop-icon", "sway/workspaces"], - "modules-right": ["custom/checkupdates", "custom/kernel", "custom/cpu", "custom/memory", "custom/getvolume", "sway/language", "custom/currentdate", "tray"], + "modules-right": ["custom/checkupdates", "custom/kernel", "custom/cpu", "custom/memory", "custom/getvolume", "custom/language", "custom/currentdate", "tray"], "sway/workspaces": { "all-outputs": false, @@ -51,6 +51,12 @@ "exec": "~/.config/waybar/scripts/get_volume.sh", }, + "custom/language": { + "format": "{}", + "interval": 10, + "exec": "~/.config/waybar/scripts/get_lang.sh", + }, + "custom/checkupdates": { "format": "{}", "interval": 1800, diff --git a/.config/waybar/scripts/cpu_info.sh b/.config/waybar/scripts/cpu_info.sh index 56c72b7..510b91f 100755 --- a/.config/waybar/scripts/cpu_info.sh +++ b/.config/waybar/scripts/cpu_info.sh @@ -4,17 +4,17 @@ check_sensor=$(sensors | grep "Tdie:" 2> /dev/null) if [ -z "${check_sensor}" ] ; then check_sensor=$(sensors | grep "Tctl:" 2> /dev/null) if [ -z "${check_sensor}" ] ; then - CPU_USAGE=$(~/.config/sway/scripts/cpu_load.sh -p) + CPU_USAGE=$(~/.config/waybar/scripts/cpu_load.sh -p) echo "$CPU_USAGE" | awk '{ printf("%6s \n"), $1, $2 }' else TEMP=$(sensors | grep 'Package id 0:\|Tctl' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o) #CPU_USAGE=$(mpstat 1 1 | awk '/Average:/ {printf("%s\n", $(NF-9))}') - CPU_USAGE=$(~/.config/sway/scripts/cpu_load.sh -p) + CPU_USAGE=$(~/.config/waybar/scripts/cpu_load.sh -p) echo "$CPU_USAGE $TEMP" | awk '{ printf("%6s @ %s \n"), $1, $2 }' fi else TEMP=$(sensors | grep 'Package id 0:\|Tdie' | grep ':[ ]*+[0-9]*.[0-9]*°C' -o | grep '+[0-9]*.[0-9]*°C' -o) #CPU_USAGE=$(mpstat 1 1 | awk '/Average:/ {printf("%s\n", $(NF-9))}') - CPU_USAGE=$(~/.config/sway/scripts/cpu_load.sh -p) + CPU_USAGE=$(~/.config/waybar/scripts/cpu_load.sh -p) echo "$CPU_USAGE $TEMP" | awk '{ printf("%6s @ %s \n"), $1, $2 }' fi diff --git a/.config/waybar/scripts/current_date.sh b/.config/waybar/scripts/current_date.sh index f223d60..3a74e1b 100755 --- a/.config/waybar/scripts/current_date.sh +++ b/.config/waybar/scripts/current_date.sh @@ -1,4 +1,4 @@ #!/bin/bash current_date=$(date "+%d/%m/%Y %H:%M") -echo "  ${current_date}" +echo " ${current_date}" diff --git a/.config/waybar/scripts/get_lang.sh b/.config/waybar/scripts/get_lang.sh new file mode 100755 index 0000000..64bb9b4 --- /dev/null +++ b/.config/waybar/scripts/get_lang.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +sway_config="${HOME}/.config/sway/config" + +if [ -f ${sway_config} ] ; then + get_lang=$(cat ${sway_config} | grep xkb_layout | grep -v "#" | head -1 | sed 's/xkb_layout//g' | cut -d '"' -f 2) + if [ -z ${get_lang} ] ; then + echo " us " + else + echo " ${get_lang} " + fi +else + echo " us " +fi diff --git a/.config/waybar/style.css b/.config/waybar/style.css index 1539a21..c4ea67a 100644 --- a/.config/waybar/style.css +++ b/.config/waybar/style.css @@ -1,6 +1,7 @@ * { border: none; border-radius: 0; + /* `otf-font-awesome` is required to be installed for icons */ font-family: UbuntuMono Nerd Font, Noto Sans, sans-serif; font-size: 15px; min-height: 0; @@ -111,6 +112,11 @@ window#waybar.chromium { margin: 0 1px; } +#custom-language { + color: #26ec6d; + margin: 0 1px; +} + #custom-clock { color: #51A6E3; margin: 0 1px;