42 lines
850 B
Nix
42 lines
850 B
Nix
{ pkgs, ... }:
|
|
with pkgs;
|
|
let
|
|
# A script that runs as long as media is playing.
|
|
isMediaPlaying = writeShellApplication {
|
|
name = "isMediaPlaying";
|
|
runtimeInputs = [
|
|
playerctl
|
|
];
|
|
text = ''
|
|
set -e
|
|
|
|
while [ "$(playerctl status)" = "Playing" ]; do
|
|
echo -n "."
|
|
sleep 1
|
|
done
|
|
'';
|
|
};
|
|
# A script that prevents the system from going to sleep while media is playing
|
|
mediaCaffeine = writeShellApplication {
|
|
name = "media-caffeine";
|
|
runtimeInputs = [
|
|
isMediaPlaying
|
|
systemd
|
|
];
|
|
text = ''
|
|
set -e
|
|
|
|
systemd-inhibit --what=sleep --why="Media is playing" --mode=block isMediaPlaying
|
|
'';
|
|
};
|
|
in
|
|
{
|
|
home.packages = with pkgs; [
|
|
pulseaudio # for pactl and other tools
|
|
pavucontrol # GUI volume control with lots of options
|
|
|
|
mediaCaffeine
|
|
];
|
|
|
|
}
|