From 737f8b1d3b6387ee53968eacd7364230efde9ee0 Mon Sep 17 00:00:00 2001 From: q3aql Date: Sun, 3 Aug 2025 15:07:48 +0200 Subject: [PATCH] Add waybar config --- .config/waybar/config | 167 ++++---------------- .config/waybar/scripts/checkUpdates.sh | 38 +++++ .config/waybar/scripts/current_date.sh | 4 + .config/waybar/scripts/get_volume.sh | 4 + .config/waybar/scripts/show_desktop_icon.sh | 3 + .config/waybar/style.css | 123 ++------------ 6 files changed, 99 insertions(+), 240 deletions(-) create mode 100755 .config/waybar/scripts/checkUpdates.sh create mode 100755 .config/waybar/scripts/current_date.sh create mode 100755 .config/waybar/scripts/get_volume.sh create mode 100755 .config/waybar/scripts/show_desktop_icon.sh diff --git a/.config/waybar/config b/.config/waybar/config index a67c8f8..9f7d756 100644 --- a/.config/waybar/config +++ b/.config/waybar/config @@ -1,143 +1,85 @@ { - // "layer": "top", // Waybar at top layer "position": "top", // Waybar position (top|bottom|left|right) - "height": 24, // Waybar height (to be removed for auto height) - // "width": 1280, // Waybar width - // Choose the order of the modules - // "modules-left": ["sway/workspaces", "sway/mode", "custom/media"], - "modules-left": ["sway/workspaces"], - // "modules-center": ["sway/window"], - //"modules-right": ["pulseaudio", "network", "cpu", "memory", "temperature", "backlight", "sway/language", "battery", "battery#bat2", "clock", "tray"], - //"modules-right": ["custom/kernel", "custom/cpu", "custom/memory", "custom/disk", "pulseaudio", "sway/language", "network", "custom/clock", "tray"], - "modules-right": ["custom/checkupdates", "custom/kernel", "custom/cpu", "custom/memory", "custom/getvolume", "sway/language", "custom/currentdate","tray"], - // Modules configuration - // "sway/workspaces": { - // "disable-scroll": true, - // "all-outputs": true, - // "format": "{name}: {icon}", - // "format-icons": { - // "1": "", - // "2": "", - // "3": "", - // "4": "", - // "5": "", - // "urgent": "", - // "focused": "", - // "default": "" - // } - // }, + "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"], + "sway/workspaces": { "all-outputs": false, - //"format": "{name}: {icon}", - "format": "{name}", + "format": "{icon}", + "icons-only": true, "format-icons": { - // "1": "", - // "2": "", - // "3": "", - // "4": "", - // "5": "", - "urgent": "", - "focused": "", - "default": "" + "1: ": " ", + "2:,": ",", + "3: ": " ", + "4: ": " ", + "5: ": " ", + "6: ": " ", + "7: ": " ", + "8: ": " ", + "9: ": " ", + "10: ": " ", + "11: ": " ", + "12: ": " ", + //"urgent": " ", + //"focused": " ", + "default": " ", } }, - "sway/mode": { - "format": "{}" + "custom/desktop-icon": { + "format": "{}", + "interval": 10, + "exec": "~/.config/waybar/scripts/show_desktop_icon.sh", }, "custom/kernel": { "format": "{}", - //"max-length": 12, "interval": 10, - "exec": "~/.config/waybar/iscripts/kernel_version.sh", - }, - - "custom/clock": { - "format": "{}", - //"max-length": 12, - "interval": 20, - "exec": "date '+%h %d, %H:%M'", + "exec": "~/.config/waybar/scripts/kernel_version.sh", }, "custom/currentdate": { "format": "{}", - //"max-length": 12, "interval": 2, - "exec": "~/.config/waybar/iscripts/current_date.sh", + "exec": "~/.config/waybar/scripts/current_date.sh", }, "custom/getvolume": { "format": "{}", - //"max-length": 12, "interval": 2, - "exec": "~/.config/waybar/iscripts/get_volume.sh", + "exec": "~/.config/waybar/scripts/get_volume.sh", }, "custom/checkupdates": { "format": "{}", - //"max-length": 12, "interval": 1800, - "exec": "~/.config/waybar/iscripts/checkUpdates.sh", + "exec": "~/.config/waybar/scripts/checkUpdates.sh", }, "custom/cpu": { "format": "{}", - //"max-length": 12, "interval": 2, - "exec": "~/.config/waybar/iscripts/cpu_info.sh", + "exec": "~/.config/waybar/scripts/cpu_info.sh", }, "custom/memory": { "format": "{}", - //"max-length": 12, "interval": 5, - "exec": "~/.config/waybar/iscripts/mem_info.sh", + "exec": "~/.config/waybar/scripts/mem_info.sh", }, "custom/disk": { "format": "{}", - //"max-length": 12, "interval": 10, - "exec": "~/.config/waybar/iscripts/disk_info.sh", + "exec": "~/.config/waybar/scripts/disk_info.sh", }, - "idle_inhibitor": { - "format": "{icon}", - "format-icons": { - "activated": "", - "deactivated": "" - } - }, "tray": { // "icon-size": 21, "spacing": 5 }, - "clock": { - // "timezone": "America/New_York", - "tooltip-format": "{:%Y %B}\n{calendar}", - "format-alt": "{:%Y-%m-%d}" - }, - "cpu": { - "format": "{usage}% ", - "tooltip": false - }, - "memory": { - "format": "{}% " - }, - "temperature": { - // "thermal-zone": 2, - // "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input", - "critical-threshold": 80, - // "format-critical": "{temperatureC}°C {icon}", - "format": "{temperatureC}°C {icon}", - "format-icons": ["", "", ""] - }, - "backlight": { - // "device": "acpi_video1", - "format": "{percent}% {icon}", - "format-icons": ["", ""] - }, + "battery": { "states": { // "good": 95, @@ -151,48 +93,5 @@ // "format-good": "", // An empty format will hide the module // "format-full": "", "format-icons": ["", "", "", "", ""] - }, - "battery#bat2": { - "bat": "BAT2" - }, - "network": { - // "interface": "wlp2*", // (Optional) To force the use of this interface - "format-wifi": "{essid} ({signalStrength}%) ", - "format-ethernet": "{ifname}: {ipaddr}/{cidr} ", - "format-linked": "{ifname} (No IP) ", - "format-disconnected": "Disconnected ⚠", - "format-alt": "{ifname}: {ipaddr}/{cidr}" - }, - "pulseaudio": { - // "scroll-step": 1, // %, can be a float - "format": "{volume}% {icon}", - //"format": "{volume}% {icon} {format_source}", - //"format-bluetooth": "{volume}% {icon} {format_source}", - //"format-bluetooth-muted": " {icon} {format_source}", - //"format-muted": " {format_source}", - //"format-source": "{volume}% ", - //"format-source-muted": "", - "format-icons": { - "headphone": "", - "hands-free": "", - "headset": "", - "phone": "", - "portable": "", - "car": "", - "default": ["", "", ""] - }, - "on-click": "pavucontrol" - }, - "custom/media": { - "format": "{icon} {}", - "return-type": "json", - "max-length": 40, - "format-icons": { - "spotify": "", - "default": "🎜" - }, - "escape": true, - "exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder - // "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name } } diff --git a/.config/waybar/scripts/checkUpdates.sh b/.config/waybar/scripts/checkUpdates.sh new file mode 100755 index 0000000..15635ae --- /dev/null +++ b/.config/waybar/scripts/checkUpdates.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Variables +checkupdates_file=/tmp/checkupdates +checkupdates_run="7200" # 2 hours + +# checkupdates file init +if [ ! -f ${checkupdates_file} ] ; then + touch ${checkupdates_file} + echo "0" > ${checkupdates_file} +else + checkupdates_value=$(cat ${checkupdates_file}) + checkupdates_incr=$(expr ${checkupdates_value} + 1) + echo "${checkupdates_incr}" > ${checkupdates_file} +fi + +# Check updates on Arch Linux +checkupdate=$(cat ${checkupdates_file}) +if [ -f /usr/bin/pacman ] ; then + if [ ${checkupdate} -ge ${checkupdates_run} ] ; then + sudo -A pacman -Syy > /dev/null 2>&1 + echo "0" > ${checkupdates_file} + fi + num_packages=$(pacman -Qu | wc -l) + echo " ${num_packages} " +# Check updates on Ubuntu/Debian/Devuan +elif [ -f /usr/bin/apt ] ; then + if [ ${checkupdate} -ge ${checkupdates_run} ] ; then + sudo -A apt-get update > /dev/null 2>&1 + echo "0" > ${checkupdates_file} + fi + num_packages=$(apt list --upgradable 2>/dev/null | grep -c ^) + num_packages=$(expr ${num_packages} - 1) + echo " ${num_packages} " +# Disable for other distros +else + echo " 0 " +fi diff --git a/.config/waybar/scripts/current_date.sh b/.config/waybar/scripts/current_date.sh new file mode 100755 index 0000000..f223d60 --- /dev/null +++ b/.config/waybar/scripts/current_date.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +current_date=$(date "+%d/%m/%Y %H:%M") +echo "  ${current_date}" diff --git a/.config/waybar/scripts/get_volume.sh b/.config/waybar/scripts/get_volume.sh new file mode 100755 index 0000000..a501178 --- /dev/null +++ b/.config/waybar/scripts/get_volume.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +get_volume=$(amixer | grep "%" | head -1 | cut -d "%" -f 1 | cut -d "[" -f 2) +echo " ${get_volume}% " diff --git a/.config/waybar/scripts/show_desktop_icon.sh b/.config/waybar/scripts/show_desktop_icon.sh new file mode 100755 index 0000000..124e5e6 --- /dev/null +++ b/.config/waybar/scripts/show_desktop_icon.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo " SWAY" diff --git a/.config/waybar/style.css b/.config/waybar/style.css index 6bd6bd3..65d49b8 100644 --- a/.config/waybar/style.css +++ b/.config/waybar/style.css @@ -2,13 +2,13 @@ border: none; border-radius: 0; /* `otf-font-awesome` is required to be installed for icons */ - font-family: UbuntuMono Nerd Font, Noto Sans, Roboto, Helvetica, Arial, sans-serif; + font-family: UbuntuMono Nerd Font, Noto Sans, sans-serif; font-size: 15px; min-height: 0; } window#waybar { - background-color: rgba(43, 48, 59, 1); + background-color: #222133; border-bottom: 1px solid rgba(100, 114, 125, 0.5); color: #ffffff; transition-property: background-color; @@ -19,17 +19,8 @@ window#waybar.hidden { opacity: 1; } -/* -window#waybar.empty { - background-color: transparent; -} -window#waybar.solo { - background-color: #FFFFFF; -} -*/ - window#waybar.termite { - background-color: #3F3F3F; + background-color: #222133; } window#waybar.chromium { @@ -40,21 +31,20 @@ window#waybar.chromium { #workspaces button { padding: 0 5px; background-color: transparent; - color: #ffffff; + color: #cccccc; /* Use box-shadow instead of border so the text isn't offset */ box-shadow: inset 0 -3px transparent; - border-radius: 0.5; + border-radius: 0.5px; } -/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ #workspaces button:hover { background: rgba(0, 0, 0, 0.2); - box-shadow: inset 0 -3px #ffffff; + box-shadow: inset 0 -3px #cccccc; } #workspaces button.focused { - background-color: #64727D; - box-shadow: inset 0 -3px #ffffff; + background-color: #664477; + box-shadow: inset 0 -3px #cccccc; } #workspaces button.urgent { @@ -62,23 +52,13 @@ window#waybar.chromium { } #mode { - background-color: #64727D; - border-bottom: 3px solid #ffffff; + background-color: #664477; + border-bottom: 3px solid #cccccc; } -#clock, -#battery, -#cpu, -#memory, -#temperature, -#backlight, -#network, -#pulseaudio, #custom-media, #tray, -#mode, -#idle_inhibitor, -#mpd { +#mode { padding: 0 10px; margin: 0 4px; color: #ffffff; @@ -89,37 +69,31 @@ window#waybar.chromium { margin: 0 4px; } -/* If workspaces is the leftmost module, omit left margin */ .modules-left > widget:first-child > #workspaces { margin-left: 0; } -/* If workspaces is the rightmost module, omit right margin */ .modules-right > widget:last-child > #workspaces { margin-right: 0; } -#clock { - background-color: #64727D; -} - #custom-disk { color: #C14F3F; margin: 0 1px; } #custom-currentdate { - color: #C14F3F; + color: #eb4d4b; margin: 0 1px; } #custom-kernel { - color: #51A6E3; + color: #62bbfa; margin: 0 1px; } #custom-cpu { - color: #B63CEC; + color: #d26bff; margin: 0 1px; } @@ -144,7 +118,7 @@ window#waybar.chromium { } #battery { - background-color: #ffffff; + background-color: #cccccc; color: #000000; } @@ -155,7 +129,7 @@ window#waybar.chromium { @keyframes blink { to { - background-color: #ffffff; + background-color: #cccccc; color: #000000; } } @@ -174,35 +148,6 @@ label:focus { background-color: #000000; } -#cpu { - background-color: #2ecc71; - color: #000000; -} - -#memory { - background-color: #9b59b6; -} - -#backlight { - background-color: #90b1b1; -} - -#network { - color: #328fff; -} - -#network.disconnected { - color: #f53c3c; -} - -#pulseaudio { - color: #d8c60d; -} - -#pulseaudio.muted { - color: #90b1b1; -} - #custom-media { background-color: #66cc99; color: #2a5c45; @@ -217,46 +162,12 @@ label:focus { background-color: #ffa000; } -#temperature { - background-color: #f0932b; -} - -#temperature.critical { - background-color: #eb4d4b; -} - #tray { /*background-color: #2980b9;*/ } -#idle_inhibitor { - background-color: #2d3436; -} - -#idle_inhibitor.activated { - background-color: #ecf0f1; - color: #2d3436; -} - -#mpd { - background-color: #66cc99; - color: #2a5c45; -} - -#mpd.disconnected { - background-color: #f53c3c; -} - -#mpd.stopped { - background-color: #90b1b1; -} - -#mpd.paused { - background-color: #51a37a; -} - #language { - color: #00b093; + color: #26ec6d; padding: 0 1px; margin: 0 1px; min-width: 16px;