From b382e491b8eb69894b5b299860705b013c34be68 Mon Sep 17 00:00:00 2001 From: opal Date: Sat, 28 Sep 2024 10:54:24 -0700 Subject: [PATCH] added script stuff to swaybar, fixed fonts --- .config/doom/config.el | 6 +- .config/sway/config | 16 ++-- .config/sway/scripts/bar.sh | 155 +++++++++++++++++++++--------------- 3 files changed, 100 insertions(+), 77 deletions(-) diff --git a/.config/doom/config.el b/.config/doom/config.el index e62d893..0808efc 100644 --- a/.config/doom/config.el +++ b/.config/doom/config.el @@ -27,9 +27,9 @@ (add-hook mode (lambda () (display-line-numbers-mode 0)))) ;; Font configuration -(set-face-attribute 'default nil :font "Monospace" :height 200) -(set-face-attribute 'fixed-pitch nil :font "Monospace" :height 200) -(set-face-attribute 'variable-pitch nil :font "ETBembo" :height 200) +(set-face-attribute 'default nil :font "Monospace" :height 190) +(set-face-attribute 'fixed-pitch nil :font "Monospace" :height 190) +(set-face-attribute 'variable-pitch nil :font "ETBembo" :height 190) (defun opal/org-font-setup () ;; Replace list hyphen with dot diff --git a/.config/sway/config b/.config/sway/config index ff6ef18..2c04853 100644 --- a/.config/sway/config +++ b/.config/sway/config @@ -203,7 +203,7 @@ exec_always pgrep -x dunst > /dev/null || dunst #exec_always pgrep -x wlsunset > /dev/null || wlsunset -l 47.6 -L -122.3 -t 2000 -T 3000 # Gammastep until wlsunset becomes a thing again: -exec_always pgrep -x gammastep > /dev/null || gammastep -l 47.6062:-122.3321 -t 4000:3500 +exec_always pgrep -x gammastep > /dev/null || gammastep -l 47.6062:-122.3321 -t 3000:2500 # udiskie - auto usb mounting exec /usr/bin/udiskie & @@ -232,13 +232,6 @@ exec hash dbus-update-activation-environment 2>/dev/null && dbus-update-activati # DECORATIONS ####################### -# SwayFX specific directions -#corner_radius 3 -#shadows enable -#default_dim_inactive 0.1 -#blur enable -#blur_xray disable - # Gaps smart_gaps off gaps inner 5 @@ -308,7 +301,7 @@ bindswitch --reload --locked lid:on output $laptop disable bindswitch --reload --locked lid:off output $laptop enable # Monitors -output HDMI-A-1 scale 2.0 +#output HDMI-A-1 scale 2.0 # Wallpaper output * bg ~/.config/wallpapers/greek-ruins.jpg fill @@ -355,9 +348,10 @@ bindsym $mod+Shift+0 move container to workspace $ws7 ####################### bar { - #swaybar_command waybar position top font "ETBembo 17" + height 40 + icon_theme "Papirus" strip_workspace_numbers yes status_command ~/.config/sway/scripts/bar.sh @@ -368,5 +362,5 @@ bar { focused_workspace #323232AA #5c5c5cAA #FFFFFFAA } - #status_command while date +'%Y-%m-%d %I:%M:%S %p'; do sleep 1; done + #swaybar_command waybar } diff --git a/.config/sway/scripts/bar.sh b/.config/sway/scripts/bar.sh index a175302..ca3b2ed 100755 --- a/.config/sway/scripts/bar.sh +++ b/.config/sway/scripts/bar.sh @@ -1,74 +1,103 @@ #!/bin/bash get_date() { - echo -n " $(date '+%Y-%m-%d %H:%M')" + echo -n " $(date '+%a %d/%m/%y %H:%M')" } get_battery() { - BATTERY_PATH="/sys/class/power_supply/BAT0" - if [ -f "$BATTERY_PATH/capacity" ]; then - BAT_PERCENT=$(cat "$BATTERY_PATH/capacity") - BAT_STATUS=$(cat "$BATTERY_PATH/status") - if [ "$BAT_STATUS" == "Charging" ]; then - echo -n "󱐋 $BAT_PERCENT%" - else - echo -n "󰁹 $BAT_PERCENT%" - fi + BATTERY_PATH="/sys/class/power_supply/BAT0" - else - echo -n "Battery not found" - fi + if [ -f "$BATTERY_PATH/capacity" ]; then + BAT_PERCENT=$(cat "$BATTERY_PATH/capacity") + BAT_STATUS=$(cat "$BATTERY_PATH/status") + + # Determine battery icon based on percentage + case $BAT_PERCENT in + 9[5-9]|100) + ICON="󰁹" # Full battery (95%-100%) + ;; + 9[0-4]) + ICON="󰂂" # 90%-94% battery + ;; + 8[0-9]) + ICON="󰂁" # 80% battery + ;; + 7[0-9]) + ICON="󰂀" # 70% battery + ;; + 6[0-9]) + ICON="󰁿" # 60% battery + ;; + 5[0-9]) + ICON="󰁾" # 50% battery + ;; + 4[0-9]) + ICON="󰁽" # 40% battery + ;; + 3[0-9]) + ICON="󰁼" # 30% battery + ;; + 2[0-9]) + ICON="󰁻" # 20% battery + ;; + 1[0-9]) + ICON="󰂃" # 10% battery + ;; + *) + ICON="󰂃" # Critical battery (less than 10%) + ;; + esac + + # Display charging icon if the battery is charging + if [ "$BAT_STATUS" == "Charging" ] || [ "$BAT_STATUS" == "Unknown" ]; then + echo -n "󱐋 $BAT_PERCENT%" + else + echo -n "$ICON $BAT_PERCENT%" + fi + + # Send notifications at critical levels + case $BAT_PERCENT in + 30) + notify-send -u normal "Battery at 30%" "Consider plugging in." + ;; + 20) + notify-send -u normal "Battery at 20%" "Battery is getting low." + ;; + 10) + notify-send -u critical "Battery at 10%" "Battery is critically low!" + ;; + [0-5]) + notify-send -u critical "Battery at 5%" "Battery is about to die!" + ;; + esac + + else + echo -n "Battery not found" + fi +} + + +get_volume() { + # Get the default sink (output device) + SINK=$(pactl info | awk -F': ' '/Default Sink/ {print $2}') + + # Get the volume percentage + VOLUME=$(pactl get-sink-volume "$SINK" | awk '{print $5}' | head -n1) + + # Get the mute status + MUTE_STATUS=$(pactl get-sink-mute "$SINK" | awk '{print $2}') + + # Check if the output is muted + if [ "$MUTE_STATUS" == "no" ]; then + # Volume is not muted, display the volume percentage + echo -n " $VOLUME" + else + # Volume is muted, display mute icon + echo -n " Muted" + fi } while true; do - echo "$(get_date) $(get_battery)" - sleep 5 + echo "$(get_volume) $(get_date) $(get_battery)" + sleep 1 done - -# #echo "🎧 $song_status $media_artist - $media_song | ⌨ $language | $network_active $interface_easyname ($ping ms) | 🏋 $loadavg_5min | $audio_active $audio_volume% | $battery_pluggedin $battery_charge | " - -# ############# -# # Commands -# ############# - -# # Audio and multimedia -# audio_volume=$(pamixer --sink `pactl list sinks short | grep RUNNING | awk '{print $1}'` --get-volume) -# audio_is_muted=$(pamixer --sink `pactl list sinks short | grep RUNNING | awk '{print $1}'` --get-mute) -# media_artist=$(playerctl metadata artist) -# media_song=$(playerctl metadata title) -# player_status=$(playerctl status) - -# # Removed weather because we are requesting it too many times to have a proper -# # refresh on the bar -# #weather=$(curl -Ss 'https://wttr.in/Pontevedra?0&T&Q&format=1') - -# if [ $battery_status = "discharging" ]; -# then -# battery_pluggedin='⚠' -# else -# battery_pluggedin='⚡' -# fi - -# if ! [ $network ] -# then -# network_active="⛔" -# else -# network_active="⇆" -# fi - -# if [ $player_status = "Playing" ] -# then -# song_status='▶' -# elif [ $player_status = "Paused" ] -# then -# song_status='⏸' -# else -# song_status='⏹' -# fi - -# if [ $audio_is_muted = "true" ] -# then -# audio_active='🔇' -# else -# audio_active='🔊' -# fr