From 9714b2fa1d670108ce811d5511fd3b7a43180647 Mon Sep 17 00:00:00 2001 From: Mastermindzh Date: Wed, 30 Oct 2019 23:37:49 +0100 Subject: [PATCH] swapped out spotify for tidal. PS: this uses the private "tidal-hifi" electron app that I am developing and should be released soon. --- i3/config | 9 ++++--- i3/i3blocks.conf | 34 +++++++++++++++----------- i3/scripts/blocks/tidal.sh | 14 +++++++++++ i3/scripts/tidal-cli.sh | 50 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 17 deletions(-) create mode 100644 i3/scripts/blocks/tidal.sh create mode 100755 i3/scripts/tidal-cli.sh diff --git a/i3/config b/i3/config index 8c13809..9f799d3 100644 --- a/i3/config +++ b/i3/config @@ -40,6 +40,7 @@ set $workspace12 " Enpass" # scripts set $spotify ~/.config/i3/scripts/spotify-cli.sh +set $tidal ~/.config/i3/scripts/tidal-cli.sh set $vpnmanager ~/.config/i3/scripts/vpn-manager.sh ############################################ @@ -147,9 +148,9 @@ bindsym XF86AudioPlay exec playerctl play bindsym XF86AudioPause exec playerctl pause bindsym XF86AudioNext exec playerctl next bindsym XF86AudioPrev exec playerctl previous -bindsym $mod+Next exec $spotify next -bindsym $mod+End exec $spotify prev -bindsym $mod+Delete exec $spotify play +bindsym $mod+Next exec $tidal next +bindsym $mod+End exec $tidal previous +bindsym $mod+Delete exec $tidal playpause ############################################ # Workspaces # @@ -309,3 +310,5 @@ exec --no-startup-id nm-applet exec_always feh --bg-scale ~/Pictures/Wallpapers/wallpaper.jpg exec /usr/bin/compton exec /bin/bash ~/.config/i3/scripts/startup.sh + +bindsym $mod+Shift+a border normal diff --git a/i3/i3blocks.conf b/i3/i3blocks.conf index 22b9777..3fe6805 100644 --- a/i3/i3blocks.conf +++ b/i3/i3blocks.conf @@ -35,11 +35,17 @@ separator_block_width=13 interval=1 color=#e29e0b -[spotify] -command=bash ~/.config/i3/scripts/blocks/spotify.sh +[tidal] +command=bash ~/.config/i3/scripts/blocks/tidal.sh separator_block_width=13 interval=1 -color=#1DB954 +color=#4293f5 + +# [spotify] +# command=bash ~/.config/i3/scripts/blocks/spotify.sh +# separator_block_width=13 +# interval=1 +# color=#1DB954 [weather] command=curl wttr.in?format=1 @@ -54,12 +60,12 @@ color=#999999 # see the script for details. [temperature] command=bash ~/.config/i3/scripts/blocks/temp.sh -label= +label= interval=1 color=#999999 [load_average] -label= +label= interval=10 separator=true color=#999999 @@ -68,7 +74,7 @@ color=#999999 # # The type defaults to "mem" if the instance is not specified. [memory] -label= +label= separator=true interval=30 color=#999999 @@ -78,7 +84,7 @@ color=#999999 # The script may be called with a optional argument to set the alert # (defaults to 10 for 10%). [disk] -label= +label= instance=/ interval=5 separator=true @@ -86,7 +92,7 @@ color=#999999 # Updates [updates] -label= +label= command=pacman -Qu | wc -l interval=60 separator=true @@ -98,15 +104,15 @@ color=#999999 # The address can be forced to IPv4 or IPv6 with -4 or -6 switches. [iface] #instance=wlan0 -label= +label= color=#0fad3c interval=10 separator=true # ping [ping] -label= -command=ping -c 2 8.8.8.8 | tail -1| awk '{print $4}' | cut -d '/' -f 2 | cut -f1 -d"." +label= +command=ping -c 2 8.8.8.8 | tail -1 | awk '{print $4}' | cut -d '/' -f 2 | cut -f1 -d"." interval=60 separator=true color=#999999 @@ -117,7 +123,7 @@ color=#999999 # The second parameter overrides the mixer selection # See the script for details. [volume] -label= +label= instance=Master interval=1 command=/usr/lib/i3blocks/volume/volume 5 pulse @@ -128,7 +134,7 @@ color=#999999 # Battery indicator # The battery instance defaults to 0. # [battery] -# label= +# label= # #instance=1 # interval=30 # separator=true @@ -145,7 +151,7 @@ color=#999999 # Date Time [time] -label= +label= command=date '+%Y-%m-%d %H:%M:%S' interval=1 separator=true diff --git a/i3/scripts/blocks/tidal.sh b/i3/scripts/blocks/tidal.sh new file mode 100644 index 0000000..e45a6cc --- /dev/null +++ b/i3/scripts/blocks/tidal.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +case $BLOCK_BUTTON in +1) ~/.config/i3/scripts/tidal-cli.sh playpause ;; # left click +4) ~/.config/i3/scripts/tidal-cli.sh next ;; # scroll up +5) ~/.config/i3/scripts/tidal-cli.sh previous ;; # scroll down +esac + +if ~/.config/i3/scripts/tidal-cli.sh status | grep 'paused' >/dev/null; then + printf ' ' # fa-pause +else + printf ' ' # fa-play +fi +~/.config/i3/scripts/tidal-cli.sh info diff --git a/i3/scripts/tidal-cli.sh b/i3/scripts/tidal-cli.sh new file mode 100755 index 0000000..dac056d --- /dev/null +++ b/i3/scripts/tidal-cli.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +TIDAL_HOST="http://localhost:47836" + +function httpGet() { + curl -s "$TIDAL_HOST/$1" +} + +function httpSilentGet() { + curl -s -o /dev/null "$TIDAL_HOST/$1" +} + +case $1 in +"play") + httpSilentGet play + ;; +"pause") + httpSilentGet pause + ;; +"playpause") + httpSilentGet playpause + ;; +"next") + httpSilentGet next + ;; +"previous") + httpSilentGet previous + ;; +"info") + JSON=$(httpGet current) + TITLE=$(echo "$JSON" | jq -r '.title') + ARTISTS=$(echo "$JSON" | jq -r '.artist') + INFO=$(echo "$TITLE - $ARTISTS") + if [ ${#INFO} -le 3 ]; then + echo "No music info available" + else + echo "$INFO" + fi + ;; +"status") + if httpGet current | grep "paused" >/dev/null; then + echo "paused" + else + echo "playing" + fi + ;; +*) + echo "tidal-cli doesn't know this command" + ;; +esac