Pause on Lock is a simple script that can pause music on Ubuntu when the lock screen kicks in.
When you return to your desktop and log back in whatever you were listening to resumes, with playback picking up exactly where it left off.
I find it useful when I’m listening to a podcast in a coffee shop— listening through my earphones, I should add; I’m not one of those people — but want to nip down to order another drink.
Instead of needing to pause Rhythmbox and then press my lock screen shortcut (Ctrl
+ Alt
+ L
) I simply press the latter and the music is automatically paused.
When, when I come back up, I pop my ear buds in, smack in my password, and I’m back in stereo.
Pause on Lock Script
Naturally you need to have a screen lock enabled to make use of this little script (on Ubuntu the lock screen automatically kicks in after a set period on new installs, and can also be assigned to a keyboard shortcut).
And keep in mind that lock screen ≠ as login screen; this script does not pause/resume if you log out and back in.
Otherwise, ‘Pause on Lock’ is compatible with Unity, GNOME Shell, Budgie, KDE, MATE and Cinnamon desktop environments. Meaning it should work pretty much everywhere.
To install it you just download the latest release as a binary file:
Next, pop open a new terminal window and run these commands:
cd ~/Downloads
sudo install pause-on-lock /usr/local/bin/
Don’t forget to add it to the list of Startup Applications if you want it to auto-load on login.
Supported music players
For Pause on Lock to do its thing you do need to be listening to music in a compatible music player for Linux.
Out-of-the-box the script works with just Rhythmbox and Spotify for Linux.
If your player of choice is something else don’t panic: there is a workaround.
Just install playerctrl
using Ubuntu Software then run the script. Any media player that supports MPRIS D-Bus Interface (i.e. most) should then work with it.
Does the ‘Pause on Lock’ script scratch a niche itch? Absolutely, and it scratches it so dang well.
To learn more about the tool head over to the ‘Pause on Lock’ Github page: