Skip to content

Commit 295b689

Browse files
author
marcelarie
committed
update eww bar config
1 parent 53c9491 commit 295b689

File tree

11 files changed

+164
-93
lines changed

11 files changed

+164
-93
lines changed

.bash_aliases

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,11 @@ alias todo="~/scripts/todos.sh"
101101
alias ftodo="~/scripts/find-todos.sh"
102102
alias retro="~/scripts/open-retro-notes.sh"
103103
alias emulator="~/Library/Android/sdk/emulator/emulator"
104-
# alias vi="nvim"
104+
alias vif="NVIM_PROFILE=full nvim"
105105
alias vi="~/scripts/vi.sh"
106106
alias feni='~/scripts/fennel-nvim.sh'
107107
alias vin="nvim-nightly"
108+
alias vinf="nvim-nightly"
108109
alias screen_shoot_partial='grim -g "$(slurp)" ~/screenshots/grim-"$(date '+%Y%m%d-%H:%M:%S')".png'
109110
alias cvi="vi"
110111
alias vico="~/scripts/vi.sh -c GitConflictListQf ."

.claude/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
"Read(./.env)",
66
"Read(./.env.*)"
77
]
8+
},
9+
"statusLine": {
10+
"type": "command",
11+
"command": "input=$(cat); cwd=$(echo \"$input\" | jq -r '.workspace.current_dir'); printf '\\033[1m%s\\033[0m' \"$(basename \"$cwd\")\"; if git -C \"$cwd\" rev-parse --is-inside-work-tree >/dev/null 2>&1 || git -C \"$cwd\" rev-parse --is-inside-git-dir >/dev/null 2>&1; then branch=$(git -C \"$cwd\" rev-parse --abbrev-ref HEAD 2>/dev/null); [ -z \"$branch\" ] && branch='(no branch)'; if git -C \"$cwd\" rev-parse --is-inside-work-tree >/dev/null 2>&1; then status_count=$(git -C \"$cwd\" status --porcelain 2>/dev/null | wc -l); else status_count=0; fi; if [ \"${status_count:-0}\" -gt 0 ]; then printf ' \\033[1;33m%s*\\033[0m' \"$branch\"; else printf ' \\033[36m%s\\033[0m' \"$branch\"; fi; elif git -C \"$cwd\" rev-parse --is-bare-repository >/dev/null 2>&1; then printf ' \\033[36m%s\\033[0m' '(bare repo)'; fi; if command -v kubectl >/dev/null 2>&1; then context=$(kubectl config view -o=jsonpath='{.current-context}' 2>/dev/null); if [ -n \"$context\" ]; then namespace=$(kubectl config view -o=jsonpath=\"{.contexts[?(@.name==\\\"${context}\\\")].context.namespace}\" 2>/dev/null); printf ' \\033[34m%s%s\\033[0m' \"$context\" \"${namespace:+:$namespace}\"; fi; fi; if [ -n \"$SSH_CONNECTION\" ]; then printf ' \\033[2m%s@%s\\033[0m' \"$(whoami)\" \"$(hostname -s)\"; fi; if [ -n \"$IN_NIX_SHELL\" ] || [[ \":$PATH:\" == *\":/nix/store:\"* ]]; then printf ' ❄️'; fi"
812
}
913
}

.config/eww/eww.scss

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,24 @@ window {
3333
}
3434
}
3535

36-
.tray.tray-active {
37-
color: $yellow;
36+
// Integrated tray styling
37+
.tray-item {
38+
padding: 4px 6px;
39+
margin: 0 2px;
40+
border-radius: 4px;
3841
}
3942

40-
.tray:hover {
41-
color: $blue;
42-
}
43-
44-
.tray button:hover {
45-
color: $blue;
46-
}
43+
menu {
44+
background-color: $black;
45+
border: 1px solid $white;
46+
color: $white;
47+
padding: 10px;
4748

48-
.tray:hover label {
49-
color: $blue;
49+
menuitem {
50+
&:hover {
51+
color: $blue;
52+
}
53+
}
5054
}
5155

5256
.player {
@@ -78,3 +82,12 @@ window {
7882
}
7983
}
8084
}
85+
86+
.calendar-text {
87+
font-family: monospace;
88+
font-size: 12px;
89+
color: $white;
90+
background-color: $black;
91+
border: 1px solid $white;
92+
padding: 8px;
93+
}

.config/eww/eww.yuck

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,14 @@
1313
:geometry (geometry :anchor "top center" :x "0%" :y "0" :width "100%" :height "20px")
1414
(bar :screen 1))
1515

16-
(defwindow tray-window0
16+
(defwindow calendar
1717
:monitor 0
18+
:exclusive false
19+
:focusable true
1820
:stacking "fg"
19-
:focusable false
20-
:windowtype "dock"
21-
:geometry (geometry :anchor "top right" :x "0" :y "4px" :width "40px" :height "100px")
22-
(tray))
21+
:geometry (geometry :anchor "top right" :x "140px" :y "2px")
22+
(calendar-widget))
2323

24-
(defwindow tray-window1
25-
:monitor 1
26-
:stacking "fg"
27-
:focusable false
28-
:windowtype "dock"
29-
:geometry (geometry :anchor "top right" :x "0" :y "4px" :width "40px" :height "100px")
30-
(tray))
3124
; foldend
3225

3326
; Bar foldstart
@@ -50,7 +43,7 @@
5043
; (noisetorch)
5144
(microphone)
5245
(speaker)
53-
(ping)
46+
; (ping)
5447
(network)
5548
(disk)
5649
(ram)
@@ -59,13 +52,14 @@
5952
(battery)
6053
(date)
6154
(time)
62-
(box :visible {screen == 0} (tray_button0))
63-
(box :visible {screen == 1} (tray_button1)))))
55+
(box :visible {screen == 0} (systray :class "tray-item" :orientation "h" :icon-size 16 :spacing 3))
56+
(box :visible {screen == 1} (systray :class "tray-item" :orientation "h" :icon-size 16 :spacing 3)))))
6457
; foldend
6558

6659
; Variables foldstart
6760
(defpoll time_poll :interval "1s" "date +%H:%M")
6861
(defpoll date_poll :interval "1m" "date +%d/%m/%Y")
62+
(defpoll calendar_poll :interval "1h" "cal")
6963
(defpoll trash_poll :interval "10s" "./modules/trash.sh")
7064
(defpoll noisetorch_poll :initial "" :interval "10s" "./modules/noisetorch.sh")
7165
(defpoll updates_poll :initial "" :interval "1m" "./modules/updates.sh &")
@@ -77,14 +71,13 @@
7771
(deflisten nvidia_listen "./modules/nvidia.sh")
7872
(deflisten notifications_listen :initial '{"show": "no", "content": ""}' "./modules/notifications.sh")
7973

80-
; Make this cleaner at some point
81-
(defpoll microphone_poll :interval "999h" "./modules/microphone.sh")
82-
(defpoll speaker_poll :interval "999h" "./modules/speaker.sh")
74+
; Audio listeners for real-time updates across all monitors
75+
(deflisten speaker_listen :initial "{\"content\": \"--\", \"icon\": \"\"}" "./modules/speaker-listen.sh")
76+
(deflisten microphone_listen :initial "{\"content\": \"--\", \"icon\": \"\"}" "./modules/microphone-listen.sh")
77+
78+
; Get active network interface dynamically
79+
(defpoll active_interface :interval "60s" :initial "tun0" "./scripts/network-interface.sh")
8380

84-
; Tray variables
85-
(defvar open_tray true)
86-
(defvar tray0_active false)
87-
(defvar tray1_active false)
8881
; foldend
8982

9083
; Modules foldstart
@@ -109,15 +102,16 @@
109102

110103
(defwidget ram []
111104
(icon-module :class "ram" :icon " " :visible {EWW_RAM.used_mem_perc != ""}
112-
(label :text "${round(EWW_RAM.used_mem_perc, 0)}%")))
105+
(button :onclick "foot btop"
106+
(label :text "${round(EWW_RAM.used_mem_perc, 0)}%"))))
113107

114108
(defwidget notifications []
115109
(icon-module :class "notifications" :icon "" :visible {notifications_listen.show == "yes"}
116110
(literal :content {notifications_listen.content})))
117111

118112
(defwidget date []
119113
(icon-module :class "date" :icon ""
120-
(eventbox :onhover "cal"
114+
(eventbox :onhover "cal" :onrightclick "eww close calendar 2>/dev/null || eww open calendar"
121115
(label :text date_poll))))
122116

123117
(defwidget time []
@@ -130,12 +124,13 @@
130124

131125
(defwidget cpu []
132126
(icon-module :class "cpu" :icon " "
133-
(button :onclick "kitty btop"
127+
(button :onclick "foot btop"
134128
(label :text "${round(EWW_CPU.avg, 0)}%"))))
135129

136130
(defwidget disk []
137131
(icon-module :class "disk" :icon ""
138-
(label :text "${round(EWW_DISK["/"].used_perc, 0)}%")))
132+
(button :onclick "foot btop"
133+
(label :text "${round(EWW_DISK["/"].used_perc, 0)}%"))))
139134

140135
(defwidget trash []
141136
(icon-module :class "trash" :icon ""
@@ -159,29 +154,34 @@
159154
(label :text ping_poll)))
160155

161156
(defwidget battery []
162-
(icon-module :class "battery" :icon ""
157+
(icon-module :class "battery" :icon "${EWW_BATTERY.BAT0.status == 'Charging' ? '' : EWW_BATTERY.BAT0.capacity >= 75 ? '' : EWW_BATTERY.BAT0.capacity >= 50 ? '' : EWW_BATTERY.BAT0.capacity >= 25 ? '' : EWW_BATTERY.BAT0.capacity >= 10 ? '' : ''}"
163158
(label :text "${EWW_BATTERY.BAT0.capacity}%")))
164159

165160
(defwidget network []
166161
(icon-module :class "network" :icon ""
167-
(label :text "${round(EWW_NET.enp42s0.NET_UP / 1000000, 2)}/${round(EWW_NET.enp42s0.NET_DOWN / 1000000, 2)}")))
162+
(button :onclick "foot btop"
163+
(label :text "${round(EWW_NET[active_interface].NET_UP / 1000000, 2)}/${round(EWW_NET[active_interface].NET_DOWN / 1000000, 2)}"))))
168164

169165
(defwidget speaker []
170166
(icon-module :class "speaker"
171-
:icon {speaker_poll.icon}
172-
(eventbox :onscroll `eww update speaker_poll="$(./modules/speaker.sh {})"`
173-
(button :onclick `eww update speaker_poll="$(./modules/speaker.sh toogle)"`
174-
(label :text {speaker_poll.content})))))
167+
:icon {speaker_listen.icon}
168+
(eventbox :onscroll `./modules/speaker.sh {}`
169+
(button :onclick `./modules/speaker.sh toogle`
170+
(label :text {speaker_listen.content})))))
175171

176172
(defwidget microphone []
177173
(icon-module :class "microphone"
178-
:icon {microphone_poll.icon}
179-
(eventbox :onscroll `eww update microphone_poll="$(./modules/microphone.sh {})"`
180-
(button :onclick `eww update microphone_poll="$(./modules/microphone.sh toogle)"`
181-
(label :text {microphone_poll.content})))))
174+
:icon {microphone_listen.icon}
175+
(eventbox :onscroll `./modules/microphone.sh {}`
176+
(button :onclick `./modules/microphone.sh toogle`
177+
(label :text {microphone_listen.content})))))
178+
179+
; Calendar popup widget
180+
(defwidget calendar-widget []
181+
(eventbox :onclick "eww close calendar"
182+
(label :text calendar_poll
183+
:class "calendar-text")))
182184

183-
; Include tray module
184-
(include "modules/tray.yuck")
185185
; foldend
186186

187187
; vim:foldmarker=foldstart,foldend
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Function to get current microphone state
4+
get_mic_state() {
5+
mute=$(pamixer --default-source --get-mute)
6+
if [ "$mute" = "true" ]; then
7+
volume="off"
8+
icon=" "
9+
else
10+
volume="$(pamixer --default-source --get-volume)%"
11+
icon=""
12+
fi
13+
echo "{\"content\": \"$volume\", \"icon\": \"$icon\"}"
14+
}
15+
16+
# Output initial state
17+
get_mic_state
18+
19+
# Listen for pulseaudio events and output state on changes
20+
# Only listen for relevant source events to reduce overhead
21+
pactl subscribe | while read -r event; do
22+
if echo "$event" | grep -E "change.*source" >/dev/null; then
23+
get_mic_state
24+
fi
25+
done

.config/eww/modules/player.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
#!/bin/sh
22

3-
43
echo "{\"show\": \"no\", \"content\": \"\"}"
5-
playerctl --follow metadata --format '{{artist}} ¿¿¿¿¿ {{ title }}' 2> /dev/null | while read -r line ; do
6-
case "$line" in
7-
?*\ ¿¿¿¿¿\ ?*) text="$(echo "$line" | sed "s/¿¿¿¿¿/-/")" && should_show="yes";;
8-
*) text="" && should_show="no" ;;
9-
esac
104

11-
echo "{\"show\": \"$should_show\", \"content\": \"(box (label :text \\\"$text\\\"))\"}"
5+
check_player() {
6+
status="$(playerctl status 2>/dev/null || echo "Stopped")"
7+
8+
# Only show if actively playing
9+
if [ "$status" = "Playing" ]; then
10+
artist="$(playerctl metadata artist 2>/dev/null || echo "")"
11+
title="$(playerctl metadata title 2>/dev/null || echo "")"
12+
13+
if [ -n "$artist" ] && [ -n "$title" ]; then
14+
text="$artist - $title"
15+
echo "{\"show\": \"yes\", \"content\": \"(box (label :text \\\"$text\\\"))\"}"
16+
return 0 # Playing
17+
fi
18+
fi
19+
20+
echo "{\"show\": \"no\", \"content\": \"\"}"
21+
return 1 # Not playing
22+
}
23+
24+
# Adaptive polling: 1s when playing, 5s when idle
25+
while true; do
26+
if check_player; then
27+
sleep 1 # Check every second when playing
28+
else
29+
sleep 5 # Check every 5 seconds when idle
30+
fi
1231
done
1332

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
# Function to get current speaker state
4+
get_speaker_state() {
5+
mute=$(pamixer --get-mute)
6+
if [ "$mute" = "true" ]; then
7+
volume="off"
8+
icon=""
9+
else
10+
volume="$(pamixer --get-volume)"
11+
if [ "$volume" -gt 66 ]; then
12+
icon=""
13+
elif [ "$volume" -gt 33 ]; then
14+
icon=""
15+
elif [ "$volume" -gt 0 ]; then
16+
icon=""
17+
else
18+
icon=""
19+
fi
20+
volume="$volume%"
21+
fi
22+
echo "{\"content\": \"$volume\", \"icon\": \"$icon \"}"
23+
}
24+
25+
# Output initial state
26+
get_speaker_state
27+
28+
# Listen for pulseaudio events and output state on changes
29+
# Only listen for relevant sink events to reduce overhead
30+
pactl subscribe | while read -r event; do
31+
if echo "$event" | grep -E "change.*sink" >/dev/null; then
32+
get_speaker_state
33+
fi
34+
done

.config/eww/modules/tray.yuck

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
# Get the active network interface (excluding loopback and docker interfaces)
3+
interface=$(ip route show default | awk '{print $5}' | head -1)
4+
# Fallback to any non-loopback interface if no default route
5+
if [[ -z "$interface" ]]; then
6+
interface=$(ip addr show | grep -E "^[0-9]+: " | awk '{print $2}' | sed 's/://' | grep -v -E "^(lo|docker|br-|veth)" | head -1)
7+
fi
8+
echo "$interface"

.config/eww/scripts/toggle_tray.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)