diff options
| author | Robert Günzler <r@gnzler.io> | 2020-12-03 13:18:26 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2020-12-07 19:28:05 +0100 |
| commit | 2e573db1d00688df71a05563b864b07916d43146 (patch) | |
| tree | 08026a613e1271b5422d9e2f18a9996192592b5c | |
| parent | 45dedcd36fcb6b5ef5dc8f7cab0df8f8ffe00fd5 (diff) | |
waybar: change icons and reorder left-side modules
| -rw-r--r-- | .config/waybar/config | 61 | ||||
| -rwxr-xr-x | .config/waybar/modules/mediaplayer.py | 18 | ||||
| -rw-r--r-- | .config/waybar/style.css | 28 |
3 files changed, 71 insertions, 36 deletions
diff --git a/.config/waybar/config b/.config/waybar/config index 27d90a6..3a2423d 100644 --- a/.config/waybar/config +++ b/.config/waybar/config @@ -1,12 +1,14 @@ -// vim: commentstring=//\ %s +// vim: ft=json commentstring=//\ %s { "layer": "top", "position": "top", - "height": 30, + "height": 25, + "gtk-layer-shell": true, - "modules-left": ["sway/mode", "sway/workspaces", "sway/window"], - "modules-center": ["custom/media", "custom/toggl", "custom/weather", "clock#local", "clock#utc"], + "modules-left": ["sway/mode", "sway/workspaces", "sway/window", "custom/mpv", "custom/mpd", "custom/spotify", "custom/toggl"], + "modules-center": ["custom/weather", "clock#local", "clock#utc"], "modules-right": ["tray", "cpu", "memory", "disk#root", "disk#home", "temperature", "idle_inhibitor", "backlight", "custom/redshift", "pulseaudio", "network#wg", "network", "battery"], + "sway/workspaces": { "disable-scroll": true, "all-outputs": false, @@ -14,7 +16,8 @@ "format-icons": { "m": "", "v": "", - "g": "" + "g": "", + "__vnc": "" } }, "sway/window": { @@ -37,7 +40,7 @@ "clock#local": { "timezone": "Europe/Berlin", "format": "{:<i>%a</i> %d %b <b>%H:%M</b>}", - "tooltip-format": "{:%Z %z}\n\n{calendar}" + "tooltip-format": "TZ: {:%Z %z}\n\n{calendar}" }, "clock#utc": { "timezone": "UTC", @@ -54,17 +57,21 @@ }, "cpu": { "format": " {}%", - "on-click": "$HOME/bin/swx -t -f htop" + "on-click": "$HOME/bin/swx -t -f -- htop --sort-key PERCENT_CPU" }, "memory": { - "format": " {}%" + "format": " {}%", + "on-click": "$HOME/bin/swx -t -f -- htop --sort-key PERCENT_MEM" }, "temperature": { - "critical-threshold": 90, + "critical-threshold": 100, "format": "{icon} {temperatureC}℃", "format-icons": ["", "", "", ""] }, "backlight": { + "states": { + "off": "1" + }, "format": "{icon} {percent}%", "format-icons": ["", "", ""], "on-scroll-down": "light -D 5", @@ -80,15 +87,15 @@ "format-charging": " {capacity}%", "format-plugged": " {capacity}%", "format-alt": "{icon} {time}", - "format-full": "{icon}", + "format-full": "", "format-icons": ["", "", "", ""] }, "network": { "format-wifi": "{icon} ({signalStrength}%)", "format-icons": ["", "", "", "", ""], "format-ethernet": " {ifname}: {ipaddr}/{cidr}", - "format-linked": " {ifname} (-)", - "format-disconnected": " (-)", + "format-linked": " {ifname}", + "format-disconnected": " ", "tooltip-format": "{ifname}: {ipaddr}/{cidr}\nssid: {essid}\nsignal: {signaldBm} dbm", "tooltip-format-disconnected": "disconnected", "on-click": "swx -t -f iwctl" @@ -119,18 +126,30 @@ "on-click-right": "pactl set-sink-mute @DEFAULT_SINK@ toggle", "on-click": "swx -t -f pulsemixer" }, - "custom/media": { - "format": "{icon} {}", + "custom/spotify": { + "format": " {}", "return-type": "json", "max-length": 80, - "format-icons": { - "spotify": "", - "mpv": "", - "default": "" - }, - "on-click": "sway [workspace=$wsMusic] focus", "escape": false, - "exec": "$HOME/.config/waybar/modules/mediaplayer.py -I chromium -I firefox 2> /dev/null" + "interval": 2, + "exec": "$HOME/.config/waybar/modules/waybar-media spotify", + "exec-if": "pgrep spotify" + }, + "custom/mpd": { + "format": " {}", + "return-type": "json", + "max-length": 80, + "interval": 2, + "exec": "$HOME/.config/waybar/modules/waybar-media mpd", + "exec-if": "pgrep mpd" + }, + "custom/mpv": { + "format": " {}", + "return-type": "json", + "max-length": 80, + "interval": 2, + "exec": "$HOME/.config/waybar/modules/waybar-media mpv", + "exec-if": "pgrep mpv" }, "custom/toggl": { "format": " {}", diff --git a/.config/waybar/modules/mediaplayer.py b/.config/waybar/modules/mediaplayer.py index 4d80ffa..8082825 100755 --- a/.config/waybar/modules/mediaplayer.py +++ b/.config/waybar/modules/mediaplayer.py @@ -7,6 +7,7 @@ import signal import sys from datetime import timedelta from math import floor +import prctl # yapf: disable import gi @@ -15,17 +16,16 @@ from gi.repository import GLib, Playerctl # yapf: enable logger = logging.getLogger(__name__) - +loop = GLib.MainLoop() def write_output(text, player): logger.info('Writing output') output = { 'text': text, - 'class': 'custom-' + player.props.player_name, + 'class': player.props.player_name, 'alt': player.props.player_name } - sys.stdout.write(json.dumps(output) + '\n') sys.stdout.flush() @@ -59,7 +59,7 @@ def on_metadata(player, metadata, manager): track_info = '{} ({})'.format(track_info, str(dur)) if player.props.status == 'Paused' and track_info: - track_info = ' ' + track_info + track_info = '<i>'+track_info+'</i>' if player.props.status == 'Stopped': return @@ -97,10 +97,10 @@ def init_player(manager, name): def signal_handler(sig, frame): - logger.debug('Received signal to stop, exiting') + logger.warning('Received signal to stop, exiting') sys.stdout.write('\n') sys.stdout.flush() - # loop.quit() + loop.quit() sys.exit(0) @@ -138,14 +138,16 @@ def main(): logger.debug('Arguments received {}'.format(vars(arguments))) manager = Playerctl.PlayerManager() - loop = GLib.MainLoop() - manager.connect('name-appeared', lambda *args: on_player_appeared(*args, arguments.player, arguments.ignore)) manager.connect('player-vanished', on_player_vanished) + # set the process up to die when the parent exits + prctl.set_pdeathsig(signal.SIGTERM) + signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) + signal.signal(signal.SIGHUP, signal_handler) for player in manager.props.player_names: if arguments.player is not None and arguments.player != player.name: diff --git a/.config/waybar/style.css b/.config/waybar/style.css index 0a0b60b..7bac15e 100644 --- a/.config/waybar/style.css +++ b/.config/waybar/style.css @@ -9,8 +9,8 @@ * { border: none; border-radius: 0; - font-family: Iosevka SS05, Noto Mono, Material Design Icons, Font Awesome; - font-size: 12pt; + font-family: Iosevka SS14, Noto Mono, Material Design Icons, Font Awesome; + font-size: 11pt; } #window, @@ -24,7 +24,9 @@ #backlight, #network, #pulseaudio, -#custom-media, +#custom-mpd, +#custom-mpv, +#custom-spotify, #custom-toggl, #custom-redshift, #custom-weather, @@ -133,6 +135,9 @@ label:focus { #cpu {} #memory {} #backlight {} +#backlight.off { + color: @dimmed; +} #network {} #network.disconnected { border-top: 2px solid @urgent; @@ -166,16 +171,22 @@ label:focus { color: unset; } -#custom-media { +#custom-mpd, +#custom-mpv, +#custom-spotify { min-width: 100px; color: @foreground; border-top: 2px solid #628aaa; } -#custom-media.custom-spotify, -#custom-media.custom-spotifyd { +#custom-mpd.paused, +#custom-mpv.paused, +#custom-spotify.paused { + color: @dimmed; +} +#custom-spotify { border-top: 2px solid #1DB954; } -#custom-media.custom-mpv { +#custom-mpv { border-top: 2px solid #520053; } @@ -211,6 +222,9 @@ label:focus { #custom-weather { color: @dimmed; } +#custom-weather.sunny { + /* color: rgba(255,206,66, 0.4); */ +} #mpd { color: @foreground; |