Skip to content
This repository was archived by the owner on Jan 2, 2024. It is now read-only.

Commit a3693f1

Browse files
committed
Better waybar config
1 parent ca5a94a commit a3693f1

File tree

11 files changed

+318
-259
lines changed

11 files changed

+318
-259
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
*.tar.gz
22
*.tar.xz
3+
.vscode

sway/conf.d/menubar

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Read `man 5 sway-bar` for more information about this section.
2-
bar {
3-
position top
4-
status_command i3status
5-
#font "Ubuntu Nerd Font" 15px
6-
font "Roboto Mono Nerd Font" 15px
7-
}
8-
92
#bar {
10-
# swaybar_command /home/luis/bin/waybar
3+
# position top
4+
# status_command i3status
5+
# #font "Ubuntu Nerd Font" 15px
6+
# font "Roboto Mono Nerd Font" 15px
117
#}
8+
9+
bar {
10+
swaybar_command /home/luis/bin/waybar
11+
}

waybar/config

Lines changed: 98 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,118 @@
11
{
2-
"layer": "top", // Waybar at top layer
3-
"position": "top", // Waybar at the bottom of your screen
4-
"height": 24, // Waybar height
5-
// "width": 1366, // Waybar width
6-
// Choose the order of the modules
7-
"modules-left": ["sway/workspaces", "sway/mode", "custom/spotify"],
8-
"modules-center": ["sway/window"],
9-
"modules-right": ["pulseaudio", "network", "cpu", "battery", "tray", "clock"],
10-
"sway/workspaces": {
11-
"disable-scroll": true,
12-
"all-outputs": false
13-
},
2+
"layer": "bottom",
3+
"position": "top",
4+
"height": 30,
5+
6+
"modules-left": ["sway/workspaces", "sway/mode"],
7+
"modules-center": ["clock"],
8+
"modules-right": ["tray", "custom/spotify", "custom/weather", "backlight", "pulseaudio", "network", "idle_inhibitor", "battery"],
149
"sway/mode": {
15-
"format": "<span style=\"italic\">{}</span>"
10+
"format": " {}"
1611
},
17-
"tray": {
18-
"icon-size": 21,
19-
"spacing": 20
12+
"sway/workspaces": {
13+
"format": "{name}",
14+
"disable-scroll": true
2015
},
21-
"clock": {
22-
"format": "{:%a, %d %b - %H:%M}"
16+
"sway/window": {
17+
"max-length": 80,
18+
"tooltip": false
2319
},
24-
"memory": {
25-
"format": "{}% "
20+
"clock": {
21+
"format": "{:%a %d %b %H:%M}",
22+
"tooltip": false
2623
},
2724
"battery": {
28-
"bat": "BAT0",
25+
"format": "{capacity}% {icon}",
26+
"format-icons": ["", "", "", "", ""],
27+
"format-charging": "{capacity}% ",
28+
"interval": 30,
2929
"states": {
30-
// "good": 95,
31-
"warning": 30,
32-
"critical": 15
30+
"warning": 25,
31+
"critical": 10
3332
},
34-
"format": "{icon} {capacity}%",
35-
// "format-good": "", // An empty format will hide the module
36-
"format-full": "Charged {icon}",
37-
"format-icons": ["", "", "", "", ""]
33+
"tooltip": false
3834
},
3935
"network": {
40-
// "interface": "wlp2s0", // (Optional) To force the use of this interface
41-
"format-wifi": "{essid} ({signalStrength}%) ",
42-
"format-ethernet": "{ifname}: {ipaddr}/{cidr} ",
43-
"format-disconnected": "Disconnected ⚠"
36+
"format": "{icon}",
37+
"format-alt": "{ipaddr}/{cidr} {icon}",
38+
"format-alt-click": "click-right",
39+
"format-icons": {
40+
"wifi": ["", "" ,""],
41+
"ethernet": [""],
42+
"disconnected": [""]
43+
},
44+
"on-click": "gnome-terminal -e nmtui",
45+
"tooltip": false
4446
},
4547
"pulseaudio": {
46-
//"scroll-step": 1,
47-
"format": "{volume}% {icon}",
48-
"format-bluetooth": "{volume}% {icon}",
49-
"format-muted": "",
48+
"format": "{icon}",
49+
"format-alt": "{volume} {icon}",
50+
"format-alt-click": "click-right",
51+
"format-muted": "",
5052
"format-icons": {
51-
"headphones": "",
52-
"handsfree": "",
53-
"headset": "",
54-
"phone": "",
55-
"portable": "",
56-
"car": "",
57-
"default": ["", ""]
53+
"phone": [" ", " ", " ", " "],
54+
"default": ["", "", "", ""]
5855
},
56+
"scroll-step": 10,
5957
"on-click": "pavucontrol",
60-
"on-scroll-up": "pactl -- set-sink-volume 0 +1%",
61-
"on-scroll-down": "pactl -- set-sink-volume 0 -1%"
58+
"tooltip": false
6259
},
6360
"custom/spotify": {
64-
"format": " {}",
65-
"max-length": 40,
66-
"interval": 30, // Remove this if your script is endless and write in loop
67-
"exec": "$HOME/.config/waybar/mediaplayer.sh 2> /dev/null", // Script in resources folder
68-
"exec-if": "pgrep spotify"
61+
"interval": 1,
62+
"return-type": "json",
63+
"exec": "~/.config/waybar/modules/spotify.sh",
64+
"exec-if": "pgrep spotify",
65+
"escape": true
66+
},
67+
"custom/storage": {
68+
"format": "{} ",
69+
"format-alt": "{percentage}% ",
70+
"format-alt-click": "click-right",
71+
"return-type": "json",
72+
"interval": 60,
73+
"exec": "~/.config/waybar/modules/storage.sh"
74+
},
75+
"backlight": {
76+
"format": "{icon}",
77+
"format-alt": "{percent}% {icon}",
78+
"format-alt-click": "click-right",
79+
"format-icons": ["", ""],
80+
"on-scroll-down": "light -A 1",
81+
"on-scroll-up": "light -U 1"
82+
},
83+
"custom/weather": {
84+
"format": "{}",
85+
"format-alt": "{alt}: {}",
86+
"format-alt-click": "click-right",
87+
"interval": 1800,
88+
"return-type": "json",
89+
"exec": "~/.config/waybar/modules/weather.sh",
90+
"exec-if": "ping wttr.in -c1"
91+
},
92+
"idle_inhibitor": {
93+
"format": "{icon}",
94+
"format-icons": {
95+
"activated": "🔓",
96+
"deactivated": ""
97+
},
98+
"tooltip": false
99+
},
100+
"custom/mail": {
101+
"format": "",
102+
"format-alt": "{alt} ",
103+
"format-alt-click": "click-right",
104+
"interval": 60,
105+
"return-type": "json",
106+
"exec": "~/.config/waybar/modules/mail.py",
107+
"tooltip": false
108+
},
109+
"custom/test": {
110+
"format": "{}",
111+
"exec": "/tmp/test blub",
112+
"param": "blah",
113+
"interval": 5
114+
},
115+
"tray": {
116+
"icon-size": 18
69117
}
70118
}

waybar/custom_modules/mediaplayer.py

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

waybar/mediaplayer.sh

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

waybar/modules/mail.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/python
2+
3+
import os
4+
import imaplib
5+
6+
import mailsecrets
7+
8+
def getmails(username, password, server):
9+
imap = imaplib.IMAP4_SSL(server, 993)
10+
imap.login(username, password)
11+
imap.select('INBOX')
12+
ustatus, uresponse = imap.uid('search', None, 'UNSEEN')
13+
if ustatus == 'OK':
14+
unread_msg_nums = uresponse[0].split()
15+
else:
16+
unread_msg_nums = []
17+
18+
fstatus, fresponse = imap.uid('search', None, 'FLAGGED')
19+
if fstatus == 'OK':
20+
flagged_msg_nums = fresponse[0].split()
21+
else:
22+
flagged_msg_nums = []
23+
24+
return [len(unread_msg_nums), len(flagged_msg_nums)]
25+
26+
ping = os.system("ping " + mailsecrets.server + " -c1 > /dev/null 2>&1")
27+
if ping == 0:
28+
mails = getmails(mailsecrets.username, mailsecrets.password, mailsecrets.server)
29+
text = ''
30+
alt = ''
31+
32+
if mails[0] > 0:
33+
text = alt = str(mails[0])
34+
if mails[1] > 0:
35+
alt = str(mails[1]) + "  " + alt
36+
else:
37+
exit(1)
38+
39+
print('{"text":"' + text + '", "alt": "' + alt + '"}')
40+
41+
else:
42+
exit(1)

waybar/modules/spotify.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
class=$(playerctl metadata --player=spotify --format '{{lc(status)}}')
4+
icon=""
5+
6+
if [[ $class == "playing" ]]; then
7+
info=$(playerctl metadata --player=spotify --format '{{artist}} - {{title}}')
8+
if [[ ${#info} > 40 ]]; then
9+
info=$(echo $info | cut -c1-40)"..."
10+
fi
11+
text=$info" "$icon
12+
elif [[ $class == "paused" ]]; then
13+
text=$icon
14+
elif [[ $class == "stopped" ]]; then
15+
text=""
16+
fi
17+
18+
echo -e "{\"text\":\""$text"\", \"class\":\""$class"\"}"

0 commit comments

Comments
 (0)