Replies: 2 comments
-
The mpris plugin has become obsolete a long time ago. A lot of plugins are community effort. If the maintainer abandons the plugin it will become unusable over time. you could go ahead and write one. this is a admittedly buggy prototype provided by gpt: import dbus
from albert import *
md_iid = '2.0'
md_version = '1.2'
md_name = 'MPRIS Control'
md_description = 'Control media playback using MPRIS'
md_url = 'https://github.com/your-username/your-repo' # Replace with your repository URL
md_bin_dependencies = []
class Plugin(PluginInstance, GlobalQueryHandler):
def __init__(self):
PluginInstance.__init__(self)
GlobalQueryHandler.__init__(self,
id="mpris_control",
name=md_name,
description=md_description,
default_trigger='mpris ')
self.dbus_session = dbus.SessionBus()
self.icon_path = iconLookup("media-playback-start")
def initialize(self):
self.players = self.get_players()
def get_players(self):
try:
players = self.dbus_session.get_object("org.mpris.MediaPlayer2", "/org/mpris/MediaPlayer2")
player_names = players.Get("org.mpris.MediaPlayer2", "KnownPlayers", dbus_interface="org.freedesktop.DBus.Properties")
return player_names
except dbus.exceptions.DBusException:
return []
def handle_global_query(self, query):
if not query.isValid or not query.string:
return
results = []
for player_name in self.players:
if query.string.lower() in player_name.lower():
results.append(self.create_action(player_name))
return results
def create_action(self, player_name):
return Item(
id=f"mpris_{player_name}",
text=player_name,
subtext="Control media playback",
icon=self.icon_path,
actions=[
FuncAction("Play/Pause", lambda player_name=player_name: self.control_media(player_name, "PlayPause")),
FuncAction("Next", lambda player_name=player_name: self.control_media(player_name, "Next")),
FuncAction("Previous", lambda player_name=player_name: self.control_media(player_name, "Previous"))
]
)
def control_media(self, player_name, action):
try:
player_obj = self.dbus_session.get_object("org.mpris.MediaPlayer2." + player_name, "/org/mpris/MediaPlayer2")
player_interface = dbus.Interface(player_obj, "org.mpris.MediaPlayer2.Player")
getattr(player_interface, action)()
except dbus.exceptions.DBusException:
pass |
Beta Was this translation helpful? Give feedback.
0 replies
-
Closing this because i unfotunately have no time to write this plugin |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
albert 0.22.2 not find MPRIS Control plugin ?
Beta Was this translation helpful? Give feedback.
All reactions