Skip to content

Instantly share code, notes, and snippets.

@TRSGuy
Created February 10, 2018 01:25
Show Gist options
  • Save TRSGuy/fa24af2a198272b0b2393be6e10d2fdd to your computer and use it in GitHub Desktop.
Save TRSGuy/fa24af2a198272b0b2393be6e10d2fdd to your computer and use it in GitHub Desktop.
#!/bin/sh
color() {
echo -n "%{F#222}"
}
nocolor() {
echo -n "%{F#000}"
}
host_is_up() {
if ping -c 1 $1 &> /dev/null
then
echo -n "%{F#FFF}${2^^}%{F#000}"
else
echo -n "%{F#222}${2^^}%{F#000}"
fi
}
clock() {
DATETIME=$(date "+%a %b %d %T")
echo -n "%{r}$DATETIME"
}
song() {
SPOT_SONG=$(python /home/vorap/Scripts/get_now_playing_spotify_linux.py)
echo -n $SPOT_SONG
}
battery() {
echo $(acpi | awk '{print(substr($3, 1, 1))}')$(acpi | awk '{print(substr($4, 1, length($4)-2))}')
}
while true; do
echo "%{F#000}%{B#90999999} \
$(python /home/vorap/Scripts/get_workspace.py) | \
$(color)$(song)$(nocolor) | \
$(color)$(ip address | grep -v "inet6" | grep "global" | awk '{print $2}' | awk -F "/" '{print $1}')$(nocolor) | \
$(host_is_up voraschem.tk V) | \
$(color)$(clock)$(nocolor) | \
$(color)$(battery)$(nocolor) "
sleep 1
done
@TRSGuy
Copy link
Author

TRSGuy commented Feb 10, 2018

#!/bin/python
import dbus
notplaying = "Nothing is playing"
session_bus = dbus.SessionBus()
try:
spotify_bus = session_bus.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2")
spotify_properties = dbus.Interface(spotify_bus, "org.freedesktop.DBus.Properties")
metadata = spotify_properties.Get("org.mpris.MediaPlayer2.Player", "Metadata")
def now_playing():
artist = str(list(metadata['xesam:artist']))[14:-3]
title = metadata['xesam:title']
if(title):
#print(metadata)
print(artist+' - '+title)
else:
print(notplaying)
now_playing()
except Exception:
print(notplaying)

@TRSGuy
Copy link
Author

TRSGuy commented Feb 10, 2018

import sys
import json
import os
js = os.popen("i3-msg -t get_workspaces").read()
j = json.loads(js)
s = []
s.append("%{l}")
for i in j:
if(i["focused"]):
s.append("%{F#FFF} " + str(i["num"]) + "%{F#000}")
else:
s.append("%{F#000} " + str(i["num"]))
s.append("%{c}")
print("".join(s))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment