diff --git a/waybar/.config/waybar/config b/waybar/.config/waybar/config index a3c3ace..7591d9f 100644 --- a/waybar/.config/waybar/config +++ b/waybar/.config/waybar/config @@ -4,7 +4,7 @@ "height": 36, // Waybar height (to be removed for auto height) // "width": 1280, // Waybar width // Choose the order of the modules - "modules-left": ["idle_inhibitor", "sway/workspaces", "custom/media", "sway/mode"], + "modules-left": ["idle_inhibitor", "sway/workspaces", "sway/mode"], "modules-center": ["clock"], "modules-right": ["custom/ivpn", "network", "pulseaudio", "cpu", "memory", "battery", "tray"], // Modules configuration @@ -103,18 +103,6 @@ }, "on-click": "/usr/bin/pavucontrol" }, - "custom/media": { - "format": "{icon} {}", - "return-type": "json", - "max-length": 48, - "format-icons": { - "chromium": "\uf1bc", // spotify (I use Spotify in my browser) - "default": "\uf001" - }, - "escape": true, - "exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder - // "exec": "$HOME/.config/waybar/mediaplayer.py --player chromium 2> /dev/null" // Filter player based on name - }, "custom/ivpn": { // Custom status module for IVPN "format": "{} IVPN", "exec": "$HOME/.config/waybar/ivpn-status.sh", diff --git a/waybar/.config/waybar/mediaplayer.py b/waybar/.config/waybar/mediaplayer.py deleted file mode 100755 index 1630d97..0000000 --- a/waybar/.config/waybar/mediaplayer.py +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env python3 -import argparse -import logging -import sys -import signal -import gi -import json -gi.require_version('Playerctl', '2.0') -from gi.repository import Playerctl, GLib - -logger = logging.getLogger(__name__) - - -def write_output(text, player): - logger.info('Writing output') - - output = {'text': text, - 'class': 'custom-' + player.props.player_name, - 'alt': player.props.player_name} - - sys.stdout.write(json.dumps(output) + '\n') - sys.stdout.flush() - - -def on_play(player, status, manager): - logger.info('Received new playback status') - on_metadata(player, player.props.metadata, manager) - - -def on_metadata(player, metadata, manager): - logger.info('Received new metadata') - track_info = '' - - if player.props.player_name == 'spotify' and \ - 'mpris:trackid' in metadata.keys() and \ - ':ad:' in player.props.metadata['mpris:trackid']: - track_info = 'AD PLAYING' - elif player.get_artist() != '' and player.get_title() != '': - track_info = '{artist} - {title}'.format(artist=player.get_artist(), - title=player.get_title()) - else: - track_info = player.get_title() - - if player.props.status != 'Playing' and track_info: - track_info = ' ' + track_info - write_output(track_info, player) - - -def on_player_appeared(manager, player, selected_player=None): - if player is not None and (selected_player is None or player.name == selected_player): - init_player(manager, player) - else: - logger.debug("New player appeared, but it's not the selected player, skipping") - - -def on_player_vanished(manager, player): - logger.info('Player has vanished') - sys.stdout.write('\n') - sys.stdout.flush() - - -def init_player(manager, name): - logger.debug('Initialize player: {player}'.format(player=name.name)) - player = Playerctl.Player.new_from_name(name) - player.connect('playback-status', on_play, manager) - player.connect('metadata', on_metadata, manager) - manager.manage_player(player) - on_metadata(player, player.props.metadata, manager) - - -def signal_handler(sig, frame): - logger.debug('Received signal to stop, exiting') - sys.stdout.write('\n') - sys.stdout.flush() - # loop.quit() - sys.exit(0) - - -def parse_arguments(): - parser = argparse.ArgumentParser() - - # Increase verbosity with every occurrence of -v - parser.add_argument('-v', '--verbose', action='count', default=0) - - # Define for which player we're listening - parser.add_argument('--player') - - return parser.parse_args() - - -def main(): - arguments = parse_arguments() - - # Initialize logging - logging.basicConfig(stream=sys.stderr, level=logging.DEBUG, - format='%(name)s %(levelname)s %(message)s') - - # Logging is set by default to WARN and higher. - # With every occurrence of -v it's lowered by one - logger.setLevel(max((3 - arguments.verbose) * 10, 0)) - - # Log the sent command line arguments - 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)) - manager.connect('player-vanished', on_player_vanished) - - signal.signal(signal.SIGINT, signal_handler) - signal.signal(signal.SIGTERM, signal_handler) - signal.signal(signal.SIGPIPE, signal.SIG_DFL) - - for player in manager.props.player_names: - if arguments.player is not None and arguments.player != player.name: - logger.debug('{player} is not the filtered player, skipping it' - .format(player=player.name) - ) - continue - - init_player(manager, player) - - loop.run() - - -if __name__ == '__main__': - main() diff --git a/waybar/.config/waybar/style.css b/waybar/.config/waybar/style.css index c35b46b..c96e4c4 100644 --- a/waybar/.config/waybar/style.css +++ b/waybar/.config/waybar/style.css @@ -82,7 +82,6 @@ window#waybar.hidden { #backlight, #network, #pulseaudio, -#custom-media, #tray, #mode, #idle_inhibitor, @@ -150,15 +149,6 @@ label:focus { box-shadow: inset 0 3px @violet; } -/*#disk { - background-color: #964B00; -} - -#backlight { - color: #66e6e6; - box-shadow: inset 0 2px #66e6e6; -}*/ - #network { color: @blue; box-shadow: inset 0 3px @blue; @@ -179,20 +169,6 @@ label:focus { box-shadow: inset 0 3px @orange; } -#custom-media { - background-color: transparent; - color: @violet; -} - -#custom-media.custom-chromium { - background-color: transparent; - color: @green; -} - -#custom-media.custom-vlc { - background-color: @orange; -} - #tray { box-shadow: inset 0 3px @blue; }