From 05a976e654d2063d00f3a80f12321efcc2252c0e Mon Sep 17 00:00:00 2001 From: Rudis Muiznieks Date: Thu, 13 Jun 2024 21:40:54 -0500 Subject: [PATCH] better swaybar status --- scripts/swaystatus.sh | 69 ++++++++++++++++++++++++++++++++-------- sway/config | 8 +---- sway/config.d/05-swaybar | 1 + zsh/zshrc | 6 ++++ 4 files changed, 64 insertions(+), 20 deletions(-) diff --git a/scripts/swaystatus.sh b/scripts/swaystatus.sh index a8eefe5..a6fd8e5 100755 --- a/scripts/swaystatus.sh +++ b/scripts/swaystatus.sh @@ -1,17 +1,60 @@ #!/usr/bin/env bash +c_dark="#181825" +c_sep="#313244" +c_bar="#89b4fa" +c_on="#a6e3a1" +c_off="#f38ba8" +c_icon="#6c7086" +separator="󰄾 " + +print_stat() { + icon=$1 + content=$2 + if [ "$icon" = "░" ]; then + icon=' ' + fi + echo -n "$icon" + printf "%3d%%" "$content" +} + +print_icon() { + icon=$1 + echo -n "$icon " +} + +read -r -d '' -a cpu < <(sicli -i cpu -p0) +read -r -d '' -a ram < <(sicli -i memory -p0) +read -r -d '' -a disk1 < <(sicli -i disk -p0 -r /) +read -r -d '' -a disk2 < <(sicli -i disk -p0 -r /home) + +timew="$(timew summary | tail -n2 | head -n1 | awk '{ print $1 }' | sed 's/:[0-9]\+$//')" +if [ "$timew" = "No" ]; then + timew="0:00" +fi +if [ "$(timew get dom.active)" = "1" ]; then + timew="+$timew" +else + timew="-$timew" +fi + +clock=$(date +'%a %b %d %H:%M') + status=$( - if [ "$(timew get dom.active)" = "1" ]; then - echo -n '+' - else - echo -n '-' - fi - time=$(timew summary | tail -n2 | head -n1 | awk '{ print $1 }' | sed 's/:[0-9]\+$//') - if [ "$time" != "No" ]; then - echo -n "$time" - else - echo -n '0:00' - fi - echo -n ' | ' - date +'%a %b %d %H:%M' + #echo -n "$blue $cpu $separator $blue󰘚 $ram $separator $blue $disk1 $blue$disk2 $separator " + print_icon "" + print_stat "${cpu[0]}" "${cpu[1]}" + echo -n " $separator " + print_icon "󰘚" + print_stat "${ram[0]}" "${ram[1]}" + echo -n " $separator " + print_icon "󰉉" + print_stat "${disk1[0]}" "${disk1[1]}" + echo -n ' ' + print_stat "${disk2[0]}" "${disk2[1]}" + echo -n " $separator " + print_icon "󱎫" + echo -n "$timew" + echo -n " $separator 󰥔 $clock" ) + echo "$status" diff --git a/sway/config b/sway/config index ecb89d8..3606a91 100644 --- a/sway/config +++ b/sway/config @@ -3,13 +3,7 @@ set $term foot set $menu fuzzel set $wobpipe /run/user/1000/wobpipe -exec dbus-update-activation-environment \ - PATH LD_LIBRARY_PATH \ - DISPLAY WAYLAND_DISPLAY SWAYSOCK \ - XDG_CURRENT_DESKTOP=sway \ - MOZ_ENABLE_WAYLAND=1 \ - ELECTRON_OZONE_PLATFORM_HINT=wayland \ - QT_QPA_PLATFORMTHEME=qt6ct +exec dbus-update-activation-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK exec mkfifo $wobpipe exec tail -f $wobpipe | wob diff --git a/sway/config.d/05-swaybar b/sway/config.d/05-swaybar index 21953b9..7b77ba6 100644 --- a/sway/config.d/05-swaybar +++ b/sway/config.d/05-swaybar @@ -2,6 +2,7 @@ bar { position top font monospace 13 status_command while ~/skynet/scripts/swaystatus.sh; do sleep 1; done + pango_markup enabled colors { background $base diff --git a/zsh/zshrc b/zsh/zshrc index ac049a1..897cbc5 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -5,6 +5,12 @@ export HISTSIZE=100000 export HISTFILE="$HOME/.zsh_history" export SAVEHIST=$HISTSIZE +# wayland env +export XDG_CURRENT_DESKTOP=sway +export MOZ_ENABLE_WAYLAND=1 +export ELECTRON_OZONE_PLATFORM_HINT=wayland +export QT_QPA_PLATFORMTHEME=qt6ct + # set zsh options and features setopt autocd autoload -Uz compinit && compinit