aboutsummaryrefslogtreecommitdiff
path: root/.local/share
diff options
context:
space:
mode:
Diffstat (limited to '.local/share')
-rw-r--r--.local/share/python-playerctl_systray/Makefile4
-rw-r--r--.local/share/python-playerctl_systray/playerctl_systray.py61
2 files changed, 65 insertions, 0 deletions
diff --git a/.local/share/python-playerctl_systray/Makefile b/.local/share/python-playerctl_systray/Makefile
new file mode 100644
index 0000000..e135452
--- /dev/null
+++ b/.local/share/python-playerctl_systray/Makefile
@@ -0,0 +1,4 @@
+compile:
+ cython3 --embed -o playerctl_systray.c -X language_level=3 playerctl_systray.py
+ PYTHON_VERSION=`ls /usr/include | grep -o 'python[3-9]\+\.[0-9]\+'` ; \
+ gcc -march=native -O2 -pipe -fno-plt -I /usr/include/$$PYTHON_VERSION -o playerctl_systray playerctl_systray.c -l$$PYTHON_VERSION -lpthread -lm -lutil -ldl `pkg-config --cflags --libs gtk+-3.0 appindicator3-0.1 dbus-1 dbus-glib-1`
diff --git a/.local/share/python-playerctl_systray/playerctl_systray.py b/.local/share/python-playerctl_systray/playerctl_systray.py
new file mode 100644
index 0000000..f5cf5e6
--- /dev/null
+++ b/.local/share/python-playerctl_systray/playerctl_systray.py
@@ -0,0 +1,61 @@
+import gi
+import subprocess
+import os
+
+gi.require_version('Gtk', '3.0')
+gi.require_version('AppIndicator3', '0.1')
+from gi.repository import Gtk, AppIndicator3
+
+class playerctl_systray:
+ def __init__(self):
+ self.indicator = AppIndicator3.Indicator.new(
+ "media-control-app",
+ "audio-x-generic",
+ AppIndicator3.IndicatorCategory.APPLICATION_STATUS
+ )
+ self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
+ self.indicator.set_menu(self.create_menu())
+
+ def create_menu(self):
+ menu = Gtk.Menu()
+
+ play_item = Gtk.MenuItem(label="Play/Pause")
+ play_item.connect("activate", self.play_pause)
+ menu.append(play_item)
+
+ next_item = Gtk.MenuItem(label="Next")
+ next_item.connect("activate", self.next_track)
+ menu.append(next_item)
+
+ prev_item = Gtk.MenuItem(label="Previous")
+ prev_item.connect("activate", self.prev_track)
+ menu.append(prev_item)
+
+ quit_item = Gtk.MenuItem(label="Quit")
+ quit_item.connect("activate", self.quit)
+ menu.append(quit_item)
+
+ menu.show_all()
+ return menu
+
+ def play_pause(self, source):
+ self.run_command("playerctl play-pause")
+
+ def next_track(self, source):
+ self.run_command("playerctl next")
+
+ def prev_track(self, source):
+ self.run_command("playerctl previous")
+
+ def run_command(self, command):
+ subprocess.run(command, shell=True)
+
+ def quit(self, source):
+ Gtk.main_quit()
+
+def main():
+ app = playerctl_systray()
+ Gtk.main()
+
+if __name__ == "__main__":
+ main()