-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: drawbu <[email protected]>
- Loading branch information
1 parent
f17c3a4
commit b94881e
Showing
6 changed files
with
43 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,6 +186,7 @@ | |
networkmanagerapplet | ||
libsForQt5.ark | ||
libsForQt5.plasma-nm | ||
playerctl | ||
|
||
git | ||
htop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Wakatime widget inspired by drawbu.""" | ||
from typing import List | ||
import subprocess | ||
|
||
from libqtile import qtile | ||
from libqtile.widget import base | ||
|
||
|
||
COVER_PATH = "/tmp/spotify-now-playing.png" | ||
|
||
|
||
def get_stdout(cmd: List[str]) -> str: | ||
try: | ||
sub = subprocess.Popen(cmd, stdout=subprocess.PIPE) | ||
except FileNotFoundError: | ||
return "" | ||
return sub.communicate()[0].decode("utf-8").strip() | ||
|
||
|
||
class SpotifyNowPlaying(base.InLoopPollText): | ||
def __init__(self, **config): | ||
super().__init__("", update_interval=5, qtile=qtile, **config) | ||
self.name = "Spotify now playing" | ||
|
||
def poll(self) -> str: | ||
is_playing = get_stdout(["playerctl", "--player=spotify", "status"]) | ||
if is_playing != "Playing": | ||
return "" | ||
artist = get_stdout(["playerctl", "--player=spotify", "metadata", "artist"]) | ||
title = get_stdout(["playerctl", "--player=spotify", "metadata", "title"]) | ||
if artist == "" or title == "": | ||
return "" | ||
return f" {artist} - {title}" |