From a15a2e2073a0dfcbcf9ce77747496ed98f64ace2 Mon Sep 17 00:00:00 2001 From: x70b1 Date: Sun, 21 Jan 2018 20:02:12 +0100 Subject: [PATCH] fix merge-probs --- .../player-mpris-tail/player-mpris-nopoll.py | 77 ------------------- .../player-mpris-tail/player-mpris-tail.py | 3 +- .../pulseaudio-fullfeatured.sh | 56 -------------- 3 files changed, 2 insertions(+), 134 deletions(-) delete mode 100755 polybar-scripts/player-mpris-tail/player-mpris-nopoll.py delete mode 100644 polybar-scripts/pulseaudio-tail/pulseaudio-fullfeatured.sh diff --git a/polybar-scripts/player-mpris-tail/player-mpris-nopoll.py b/polybar-scripts/player-mpris-tail/player-mpris-nopoll.py deleted file mode 100755 index 3a3eb2c..0000000 --- a/polybar-scripts/player-mpris-tail/player-mpris-nopoll.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python3 - -import time -import sys - -import gi -gi.require_version('Playerctl', '1.0') -from gi.repository import Playerctl, GLib - -MUSIC_ICON = '#1' -PAUSE_ICON = '#2' -PLAYER_CLOSED_ICON = '#3' - - -class PlayerStatus: - def __init__(self): - self._player = None - self._icon = PAUSE_ICON - - self._last_artist = None - self._last_title = None - - self._last_status = '' - - def show(self): - self._init_player() - - # Wait for events - main = GLib.MainLoop() - main.run() - - def _init_player(self): - while True: - try: - self._player = Playerctl.Player() - self._player.on('metadata', self._on_metadata) - self._player.on('play', self._on_play) - self._player.on('pause', self._on_pause) - self._player.on('exit', self._on_exit) - break - - except: - self._print_flush(PLAYER_CLOSED_ICON) - time.sleep(2) - - def _on_metadata(self, player, e): - if 'xesam:artist' in e.keys() and 'xesam:title' in e.keys(): - self._artist = e['xesam:artist'][0] - self._title = e['xesam:title'] - self._print_song() - - def _on_play(self, player): - self._icon = MUSIC_ICON - self._print_song() - - def _on_pause(self, player): - self._icon = PAUSE_ICON - self._print_song() - - def _on_exit(self, player): - self._init_player() - - def _print_song(self): - self._print_flush( - '{} {} - {}'.format(self._icon, self._artist, self._title)) - - """ - Seems to assure print() actually prints when no terminal is connected - """ - - def _print_flush(self, status, **kwargs): - if status != self._last_status: - print(status, **kwargs) - sys.stdout.flush() - self._last_status = status - -PlayerStatus().show() diff --git a/polybar-scripts/player-mpris-tail/player-mpris-tail.py b/polybar-scripts/player-mpris-tail/player-mpris-tail.py index dbaf41d..3a3eb2c 100755 --- a/polybar-scripts/player-mpris-tail/player-mpris-tail.py +++ b/polybar-scripts/player-mpris-tail/player-mpris-tail.py @@ -9,6 +9,7 @@ from gi.repository import Playerctl, GLib MUSIC_ICON = '#1' PAUSE_ICON = '#2' +PLAYER_CLOSED_ICON = '#3' class PlayerStatus: @@ -39,7 +40,7 @@ class PlayerStatus: break except: - self._print_flush('') + self._print_flush(PLAYER_CLOSED_ICON) time.sleep(2) def _on_metadata(self, player, e): diff --git a/polybar-scripts/pulseaudio-tail/pulseaudio-fullfeatured.sh b/polybar-scripts/pulseaudio-tail/pulseaudio-fullfeatured.sh deleted file mode 100644 index 4c048f2..0000000 --- a/polybar-scripts/pulseaudio-tail/pulseaudio-fullfeatured.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh - -sink=0 - -volume_up() { - pactl set-sink-volume $sink +1% -} - -volume_down() { - pactl set-sink-volume $sink -1% -} - -volume_mute() { - pactl set-sink-mute $sink toggle -} - -volume_print() { - muted=$(pamixer --sink $sink --get-mute) - - if [ "$muted" = true ]; then - echo "#1 --" - else - volume=$(pamixer --sink $sink --get-volume) - - if [ "$volume" -lt 50 ]; then - echo "#2 $volume %" - else - echo "#3 $volume %" - fi - fi -} - -listen() { - volume_print - - pactl subscribe | while read -r event; do - if echo "$event" | grep -q "#$sink"; then - volume_print - fi - done -} - -case "$1" in - --up) - volume_up - ;; - --down) - volume_down - ;; - --mute) - volume_mute - ;; - *) - listen - ;; -esac