aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i3/config8
-rw-r--r--i3/conkyrc.json9
-rwxr-xr-xscripts/i3_use_fish.sh8
-rw-r--r--scripts/media_control.sh36
-rw-r--r--scripts/media_next.fish5
-rw-r--r--scripts/media_prev.fish5
-rw-r--r--scripts/media_toggle.fish5
-rw-r--r--scripts/spotify-artist-title.sh14
8 files changed, 59 insertions, 31 deletions
diff --git a/i3/config b/i3/config
index 416d2ae..a6ca140 100644
--- a/i3/config
+++ b/i3/config
@@ -178,10 +178,9 @@ bindsym XF86AudioLowerVolume exec amixer -q set Master 10%-
bindsym XF86AudioRaiseVolume exec amixer -q set Master 10%+
bindsym XF86AudioMute exec amixer -q set Master toggle
# # Music
-bindsym XF86AudioPrev exec bash -c "~/.dotfiles/scripts/i3_use_fish.sh ~/.dotfiles/scripts/media_prev.fish"
-bindsym XF86AudioPlay exec bash -c "~/.dotfiles/scripts/i3_use_fish.sh ~/.dotfiles/scripts/media_toggle.fish"
-bindsym XF86AudioNext exec bash -c "~/.dotfiles/scripts/i3_use_fish.sh ~/.dotfiles/scripts/media_next.fish"
-
+bindsym XF86AudioPrev exec bash ~/.dotfiles/scripts/media_control.sh prev
+bindsym XF86AudioPlay exec bash ~/.dotfiles/scripts/media_control.sh toggle
+bindsym XF86AudioNext exec bash ~/.dotfiles/scripts/media_control.sh next
## brightnescontroll
bindsym XF86MonBrightnessUp exec /usr/bin/xbacklight +10
@@ -220,4 +219,3 @@ exec --no-startup-id mpd
# Please remove the following exec line:
#######################################################################
exec i3-config-wizard
-
diff --git a/i3/conkyrc.json b/i3/conkyrc.json
index b192bb8..196f2c3 100644
--- a/i3/conkyrc.json
+++ b/i3/conkyrc.json
@@ -41,12 +41,15 @@ TEXT
#{"name": "disk", "color": "\#ffffff", "full_text": " ${fs_used_perc /}%"},
- ############### music / mpd ###################
+ ############### music/ spotify/ mpd ###################
${if_match "${nodename_short}"!="fishbowl"}
- ${if_mpd_playing}
- # {"name": "test status", "full_text":"${mpd_status}", "separator":false},
+ ${if_match "${exec lsof | grep /dev/snd | grep spotify}"!=""} # spotify using sound devices -> is playing
+ {"name": "indicator", "separator": false ,"color": "\#ffffff", "full_text": "Spotify:"},
+ {"name": "artist_title", "color": "\#ffffff", "full_text": "${exec bash ~/.dotfiles/scripts/spotify-artist-title.sh}"},
+ ${else} ${if_mpd_playing}
+ {"name": "indicator", "separator": false, "color": "\#ffffff", "full_text": "MPD:"},
{"name": "statusSymbol", "color": "\#ffffff", "separator": false,
"full_text": ${if_match "${mpd_status}"=="Playing"}"▶"${else}"▐▐"${endif}},
diff --git a/scripts/i3_use_fish.sh b/scripts/i3_use_fish.sh
deleted file mode 100755
index 25435fd..0000000
--- a/scripts/i3_use_fish.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-if type fish &>/dev/null
-then
- exec fish $1
-else
- exec i3-nagbar -m "please install fish to use this script $1"
-fi
diff --git a/scripts/media_control.sh b/scripts/media_control.sh
new file mode 100644
index 0000000..c0ce02a
--- /dev/null
+++ b/scripts/media_control.sh
@@ -0,0 +1,36 @@
+# NOTE:
+# if spotify is running toggle is consumed by spotify.
+
+#!/bin/bash
+
+# arg parsing
+if [ "$1" = "toggle" ]
+then
+ spotify_cmd="PlayPause"
+elif [ "$1" = "next" ]
+then
+ spotify_cmd="Next"
+elif [ "$1" = "prev" ]
+then
+ spotify_cmd="Previous"
+fi
+
+if [ "$spotify_cmd" != "" ]
+then
+ # can't be sure if spotify was running and should play again
+ if [ "$spotify_cmd" = "PlayPause" ]
+ then
+ if [ "$(ps -A | grep spotify)" != "" ]
+ then
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.$spotify_cmd
+ else
+ mpc $1
+ fi
+ elif [ "$(lsof | grep /dev/snd | grep spotify)" != "" ]
+ then
+ dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.$spotify_cmd
+ elif [ "$(mpc | grep '\[' | cut -f1 -d' ')" != "" ]
+ then
+ mpc $1 &>/dev/null
+ fi
+fi
diff --git a/scripts/media_next.fish b/scripts/media_next.fish
deleted file mode 100644
index 173d9fc..0000000
--- a/scripts/media_next.fish
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/fish
-
-if type mpc >/dev/null 2>/dev/null
- mpc next >/dev/null 2>/dev/null
-end
diff --git a/scripts/media_prev.fish b/scripts/media_prev.fish
deleted file mode 100644
index e29bc88..0000000
--- a/scripts/media_prev.fish
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/fish
-
-if type mpc >/dev/null 2>/dev/null
- mpc prev >/dev/null 2>/dev/null
-end
diff --git a/scripts/media_toggle.fish b/scripts/media_toggle.fish
deleted file mode 100644
index e826122..0000000
--- a/scripts/media_toggle.fish
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/fish
-
-if type mpc >/dev/null 2>/dev/null
- mpc toggle >/dev/null 2>/dev/null
-end
diff --git a/scripts/spotify-artist-title.sh b/scripts/spotify-artist-title.sh
new file mode 100644
index 0000000..62494b8
--- /dev/null
+++ b/scripts/spotify-artist-title.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+metadata=$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata')
+
+if [[ $metadata == *"spotify:ad"* ]]
+then
+ echo "ad :/"
+else
+ 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 ^$)
+
+ echo $artist - $title
+fi