|
|
@@ -0,0 +1,16 @@ |
|
|
|
#!/usr/bin/env bash |
|
|
|
|
|
|
|
# MPRIS = Media Player Remote Interfacing Specification |
|
|
|
firefox_mpris_dbus=$(dbus-send --print-reply --dest=org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep -Po "org.mpris.*firefox[^\"]+") |
|
|
|
|
|
|
|
if [ -n ${firefox_mpris_dbus} ]; then |
|
|
|
playback_string=$(dbus-send --print-reply --dest=${firefox_mpris_dbus} /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'PlaybackStatus' | grep -Po "(?<=string \")[^\"]+") |
|
|
|
fi |
|
|
|
|
|
|
|
# Suspend Firefox processes if not playing media |
|
|
|
if [ -z "${playback_string}" ] || [ "${playback_string}" != "Playing" ]; then |
|
|
|
ps aux | grep [f]irefox/[f]irefox | awk '{print $2}' | xargs -P0 -I {} kill -STOP {} |
|
|
|
fi |
|
|
|
|
|
|
|
# Suspend Atom processes |
|
|
|
ps aux | grep "/[a]tom" | awk '{print $2}' | xargs -P0 -I {} kill -STOP {} |