Skip to content

Commit

Permalink
Fix notification priority for music control
Browse files Browse the repository at this point in the history
  • Loading branch information
fortes committed Nov 30, 2023
1 parent 5c4d89c commit b2feff0
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions stowed-files/playerctl/.local/bin/music-control
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,27 @@ def get_track_info(player):

# In priority order, use: `notify-send`, `tmux`, shell output
def notify(msg, opts={}):
title = opts.get("title", None) or 'Music'
title = opts.get("title", None) or "Music"
if os.environ.get("WAYLAND_DISPLAY"):
app_name = opts.get("app_name", None) or "Music"
icon = opts.get("icon", None) or "audio-headphones-symbolic"
urgency = opts.get("urgency", None) or "low"
optional_args = []
if opts.get("transient", None):
optional_args.append("--transient")
if urgency == "low":
optional_args.append("--expire-time=1000")
subprocess.run(
[
"notify-send",
"--app-name=%s" % app_name,
"--urgency=%s" % urgency,
"--icon=%s" % icon,
title,
msg,
]
(
[
"notify-send",
"--app-name=%s" % app_name,
"--urgency=%s" % urgency,
"--icon=%s" % icon,
title,
msg,
] + optional_args
)
)
elif os.environ.get("TMUX"):
subprocess.run(
Expand Down Expand Up @@ -134,6 +141,8 @@ def main():
get_track_info(selected_player),
{
"app_name": selected_name,
"urgency": "low",
"transient": True,
"title": "Paused" if selected_status == "Playing" else "Playing",
},
)
Expand All @@ -149,11 +158,16 @@ def main():
get_track_info(selected_player),
{
"app_name": selected_name,
"urgency": "low",
"transient": True,
"title": action.capitalize(),
},
)
else:
notify("Invalid argument %s. Use 'play/pause', 'previous', or 'next'." % action)
notify(
"Invalid argument %s. Use 'play/pause', 'previous', or 'next'." % action,
{"app_name": selected_name, "urgency": "critical"},
)
sys.exit(1)


Expand Down

0 comments on commit b2feff0

Please sign in to comment.