From 98b56b0cb066044366bc98edf31aa78a04fb13d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Sat, 22 Sep 2018 20:21:09 +0200 Subject: [PATCH] Enable kdeconnect-indicator; only show spotify info if spotify is running --- config.nix | 5 ++++- configs/graphics.nix | 42 ++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/config.nix b/config.nix index 47f6b9f..efa8e28 100644 --- a/config.nix +++ b/config.nix @@ -141,7 +141,10 @@ in { }; }; - services.kdeconnect.enable = true; + services.kdeconnect = { + enable = true; + indicator = true; + }; services.dunst = with import ./theme.nix; { enable = true; diff --git a/configs/graphics.nix b/configs/graphics.nix index 90c9768..32f77a7 100644 --- a/configs/graphics.nix +++ b/configs/graphics.nix @@ -1,28 +1,30 @@ { pkgs, lib, config, ... }: let spotify_info = pkgs.writeBash "spotify.info" '' - STATUS=$(${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$) + if $(pgrep spotify); then + STATUS=$(${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus'|egrep -A 1 "string"|cut -b 26-|cut -d '"' -f 1|egrep -v ^$) - if [[ "$STATUS" == 'Playing' ]]; then - printf '\uf1bc ' - printf '\uf04b' - elif [[ "$STATUS" == 'Paused' ]]; then - printf '\uf1bc ' - printf '\uf04c' - elif [[ "$STATUS" == 'Stopped' ]]; then - printf '\uf1bc ' - printf '\uf04d' - else - exit 1 + if [[ "$STATUS" == 'Playing' ]]; then + printf '\uf1bc ' + printf '\uf04b' + elif [[ "$STATUS" == 'Paused' ]]; then + printf '\uf1bc ' + printf '\uf04c' + elif [[ "$STATUS" == 'Stopped' ]]; then + printf '\uf1bc ' + printf '\uf04d' + else + exit 1 + fi + + printf ' ' + + METADATA=$(${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata') + ARTIST=$(echo "$METADATA" | egrep -A 2 "artist" | egrep -v "artist" | egrep -v "array" | cut -b 27- | cut -d '"' -f 1 | egrep -v ^$) + TITLE=$(echo "$METADATA" | egrep -A 1 "title" | egrep -v "title" | cut -b 44- | cut -d '"' -f 1 | egrep -v ^$) + + printf "%s \u2237 %s" "$ARTIST" "$TITLE" fi - - printf ' ' - - METADATA=$(${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata') - ARTIST=$(echo "$METADATA" | egrep -A 2 "artist" | egrep -v "artist" | egrep -v "array" | cut -b 27- | cut -d '"' -f 1 | egrep -v ^$) - TITLE=$(echo "$METADATA" | egrep -A 1 "title" | egrep -v "title" | cut -b 44- | cut -d '"' -f 1 | egrep -v ^$) - - printf "%s \u2237 %s" "$ARTIST" "$TITLE" ''; battery_info = pkgs.writeBash "battery.info" '' BAT_DIR="/sys/class/power_supply/$BLOCK_INSTANCE/"