summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.config/polybar/config##desktop.Linux.Lowe36
-rw-r--r--.config/polybar/config##desktop.Linux.Maus2
-rwxr-xr-x.config/polybar/pulseaudio-control.sh2
-rw-r--r--.config/polybar/spotify_status.py123
4 files changed, 151 insertions, 12 deletions
diff --git a/.config/polybar/config##desktop.Linux.Lowe b/.config/polybar/config##desktop.Linux.Lowe
index f0670d5..488edc4 100644
--- a/.config/polybar/config##desktop.Linux.Lowe
+++ b/.config/polybar/config##desktop.Linux.Lowe
@@ -52,7 +52,7 @@ font-1 = Lato:size=10;1
52font-2 = Raleway:size=10;1 52font-2 = Raleway:size=10;1
53font-3 = FuraCode Nerd Font:size=11;2 53font-3 = FuraCode Nerd Font:size=11;2
54 54
55modules-left = i3 pulseaudio spotify 55modules-left = i3 pulseaudio-control spotify
56modules-center = xwindow 56modules-center = xwindow
57modules-right = focus date time xkeyboard 57modules-right = focus date time xkeyboard
58 58
@@ -96,8 +96,8 @@ y-offset = 10
96label-padding = 1 96label-padding = 1
97label-font = 1 97label-font = 1
98 98
99label-empty = 99label-empty =
100label-empty-font = 4 100label-empty-font = 3
101label-empty-padding = 5 101label-empty-padding = 5
102 102
103[module/xkeyboard] 103[module/xkeyboard]
@@ -108,11 +108,11 @@ blacklist-1 = scroll lock
108format = <label-layout> <label-indicator> 108format = <label-layout> <label-indicator>
109format-spacing = 0 109format-spacing = 0
110 110
111format-prefix = 111format-prefix =
112format-prefix-padding = 1 112format-prefix-padding = 1
113format-prefix-background = ${colors.blue} 113format-prefix-background = ${colors.blue}
114format-prefix-foreground = ${colors.foreground} 114format-prefix-foreground = ${colors.foreground}
115format-prefix-font = 4 115format-prefix-font = 3
116 116
117label-layout = %layout% 117label-layout = %layout%
118label-layout-padding = 1 118label-layout-padding = 1
@@ -202,7 +202,7 @@ format = <label>
202format-prefix =  202format-prefix = 
203format-prefix-background = ${colors.orange} 203format-prefix-background = ${colors.orange}
204format-prefix-foreground = ${colors.foreground} 204format-prefix-foreground = ${colors.foreground}
205format-prefix-font = 4 205format-prefix-font = 3
206format-prefix-padding = 1 206format-prefix-padding = 1
207 207
208label-background = ${colors.background_modules} 208label-background = ${colors.background_modules}
@@ -217,10 +217,10 @@ time = %H:%M
217label = %time% 217label = %time%
218format = <label> 218format = <label>
219 219
220format-prefix = 220format-prefix =
221format-prefix-background = ${colors.secondary} 221format-prefix-background = ${colors.secondary}
222format-prefix-foreground = ${colors.foreground} 222format-prefix-foreground = ${colors.foreground}
223format-prefix-font = 4 223format-prefix-font = 3
224format-prefix-padding = 1 224format-prefix-padding = 1
225 225
226label-background = ${colors.background_modules} 226label-background = ${colors.background_modules}
@@ -233,10 +233,10 @@ interval = 5
233 233
234format-volume = <label-volume> 234format-volume = <label-volume>
235 235
236format-volume-prefix = 236format-volume-prefix =
237format-volume-prefix-background = ${colors.purple} 237format-volume-prefix-background = ${colors.purple}
238format-volume-prefix-foreground = ${colors.background_modules} 238format-volume-prefix-foreground = ${colors.background_modules}
239format-volume-prefix-font = 4 239format-volume-prefix-font = 3
240format-volume-prefix-padding = 1 240format-volume-prefix-padding = 1
241 241
242label-volume = %percentage% 242label-volume = %percentage%
@@ -249,6 +249,22 @@ label-muted-background = ${colors.purple}
249label-muted-foreground = ${colors.foreground} 249label-muted-foreground = ${colors.foreground}
250label-muted-padding = 2 250label-muted-padding = 2
251 251
252[module/pulseaudio-control]
253type = custom/script
254tail = true
255label = %output%
256interval = 5
257
258exec = ~/.config/polybar/pulseaudio-control.sh --listen
259click-right = exec pavucontrol &
260click-left = ~/.config/polybar/pulseaudio-control.sh --togmute
261click-middle = ~/.config/polybar/pulseaudio-control.sh --change
262scroll-up = ~/.config/polybar/pulseaudio-control.sh --up
263scroll-down = ~/.config/polybar/pulseaudio-control.sh --down
264label-padding = 2
265label-foreground = ${colors.foreground_modules}
266label-background = ${colors.background_modules}
267
252[settings] 268[settings]
253screenchange-reload = true 269screenchange-reload = true
254compositing-background = source 270compositing-background = source
diff --git a/.config/polybar/config##desktop.Linux.Maus b/.config/polybar/config##desktop.Linux.Maus
index f9686ae..0c8ce3d 100644
--- a/.config/polybar/config##desktop.Linux.Maus
+++ b/.config/polybar/config##desktop.Linux.Maus
@@ -52,7 +52,7 @@ font-1 = Lato:size=10;1
52font-2 = Raleway:size=10;1 52font-2 = Raleway:size=10;1
53font-3 = FuraCode Nerd Font:size=12;2 53font-3 = FuraCode Nerd Font:size=12;2
54 54
55modules-left = i3 mpd pulseaudio-control 55modules-left = i3 pulseaudio-control mpd
56modules-center = xwindow 56modules-center = xwindow
57modules-right = focus date time xkeyboard 57modules-right = focus date time xkeyboard
58 58
diff --git a/.config/polybar/pulseaudio-control.sh b/.config/polybar/pulseaudio-control.sh
index e88ce39..bdabf2f 100755
--- a/.config/polybar/pulseaudio-control.sh
+++ b/.config/polybar/pulseaudio-control.sh
@@ -14,7 +14,7 @@ VOLUME_ICONS=( " " " " " " ) # Volume icons array, from lower volume t
14MUTED_ICON=" " # Muted volume icon 14MUTED_ICON=" " # Muted volume icon
15MUTED_COLOR="%{F#A9AA83}" # Color when the audio is muted 15MUTED_COLOR="%{F#A9AA83}" # Color when the audio is muted
16DEFAULT_SINK_ICON="♫ " # The default sink icon if a custom one isn't found 16DEFAULT_SINK_ICON="♫ " # The default sink icon if a custom one isn't found
17CUSTOM_SINK_ICONS=("" "" "") # Custom sink icons in index of sink order 17CUSTOM_SINK_ICONS=("" "") # Custom sink icons in index of sink order
18NOTIFICATIONS="yes" # Notifications when switching sinks if enabled 18NOTIFICATIONS="yes" # Notifications when switching sinks if enabled
19SINK_BLACKLIST=( ) # Index blacklist for sinks when switching between them 19SINK_BLACKLIST=( ) # Index blacklist for sinks when switching between them
20 20
diff --git a/.config/polybar/spotify_status.py b/.config/polybar/spotify_status.py
new file mode 100644
index 0000000..3a56096
--- /dev/null
+++ b/.config/polybar/spotify_status.py
@@ -0,0 +1,123 @@
1#!/bin/python
2
3import sys
4import dbus
5import argparse
6
7parser = argparse.ArgumentParser()
8parser.add_argument(
9 '-t',
10 '--trunclen',
11 type=int,
12 metavar='trunclen'
13)
14parser.add_argument(
15 '-f',
16 '--format',
17 type=str,
18 metavar='custom format',
19 dest='custom_format'
20)
21parser.add_argument(
22 '-p',
23 '--playpause',
24 type=str,
25 metavar='play-pause indicator',
26 dest='play_pause'
27)
28parser.add_argument(
29 '--font',
30 type=str,
31 metavar='the index of the font to use for the main label',
32 dest='font'
33)
34parser.add_argument(
35 '--playpause-font',
36 type=str,
37 metavar='the index of the font to use to display the playpause indicator',
38 dest='play_pause_font'
39)
40
41
42args = parser.parse_args()
43
44def fix_string(string):
45 # corrects encoding for the python version used
46 if sys.version_info.major == 3:
47 return string
48 else:
49 return string.encode('utf-8')
50
51# Default parameters
52output = fix_string(u'{play_pause} {artist}: {song}')
53trunclen = 25
54play_pause = fix_string(u'\u25B6,\u23F8') # first character is play, second is paused
55
56label_with_font = '%{{T{font}}}{label}%{{T-}}'
57font = args.font
58play_pause_font = args.play_pause_font
59
60# parameters can be overwritten by args
61if args.trunclen is not None:
62 trunclen = args.trunclen
63if args.custom_format is not None:
64 output = args.custom_format
65if args.play_pause is not None:
66 play_pause = args.play_pause
67
68try:
69 session_bus = dbus.SessionBus()
70 spotify_bus = session_bus.get_object(
71 'org.mpris.MediaPlayer2.spotify',
72 '/org/mpris/MediaPlayer2'
73 )
74
75 spotify_properties = dbus.Interface(
76 spotify_bus,
77 'org.freedesktop.DBus.Properties'
78 )
79
80 metadata = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'Metadata')
81 status = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus')
82
83 # Handle play/pause label
84
85 play_pause = play_pause.split(',')
86
87 if status == 'Playing':
88 play_pause = play_pause[0]
89 elif status == 'Paused':
90 play_pause = play_pause[1]
91 else:
92 play_pause = str()
93
94 if play_pause_font:
95 play_pause = label_with_font.format(font=play_pause_font, label=play_pause)
96
97 # Handle main label
98
99 artist = fix_string(metadata['xesam:artist'][0]) if metadata['xesam:artist'] else ''
100 song = fix_string(metadata['xesam:title']) if metadata['xesam:title'] else ''
101 album = fix_string(metadata['xesam:album']) if metadata['xesam:album'] else ''
102
103 if not artist and not song and not album:
104 print('')
105 else:
106 if len(song) > trunclen:
107 song = song[0:trunclen]
108 song += '...'
109 if ('(' in song) and (')' not in song):
110 song += ')'
111
112 if font:
113 artist = label_with_font.format(font=font, label=artist)
114 song = label_with_font.format(font=font, label=song)
115 album = label_with_font.format(font=font, label=album)
116
117 print(output.format(artist=artist, song=song, play_pause=play_pause, album=album))
118
119except Exception as e:
120 if isinstance(e, dbus.exceptions.DBusException):
121 print('')
122 else:
123 print(e)