diff --git a/configurations/desktop/configuration.nix b/configurations/desktop/configuration.nix index 91ed87dc..90d30dea 100644 --- a/configurations/desktop/configuration.nix +++ b/configurations/desktop/configuration.nix @@ -79,8 +79,6 @@ Group = "root"; }; script = " - # This service appears to have issues when system sleeps - stop service - systemctl -M 'cspark@' --user stop mpd-discord-rpc.service # Unbind audio interface echo `grep 0a73 /sys/bus/usb/devices/*/idVendor | cut -d '/' -f 6` > /sys/bus/usb/drivers/usb/unbind # Remove snd_usb_audio once no longer in use @@ -104,8 +102,6 @@ modprobe snd_usb_audio # Rebind audio interface echo `grep 0a73 /sys/bus/usb/devices/*/idVendor | cut -d '/' -f 6` > /sys/bus/usb/drivers/usb/bind - # This service appears to have issues when system sleeps - start service - systemctl -M 'cspark@' --user start mpd-discord-rpc.service "; }; diff --git a/global-home.nix b/global-home.nix index 35335447..205039f0 100644 --- a/global-home.nix +++ b/global-home.nix @@ -61,6 +61,8 @@ in kdenlive vlc + mpdcron + pass-wayland thunderbird @@ -72,6 +74,35 @@ in libnotify ]; + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + # ".local/share/applications/ncmpcpp.desktop".text = '' + # [Desktop Entry] + # Name=NCMPCPP + # Comment=Run ncurses music player CPP + # Categories=Other; + # Icon=konsole + # Type=Application + # Exec=konsole -e ncmpcpp + # Terminal=false + # ''; + + # MPDCRON Configuration + ".mpdcron/mpdcron.conf".source = ./global-resources/home-manager/.mpdcron/mpdcron.conf; + ".mpdcron/hooks/player".source = ./global-resources/home-manager/.mpdcron/hooks/player; + }; + # Have to enable the mpd and mpd-discord-rpc user services manually for now services.mpd = { enable = true; @@ -135,35 +166,16 @@ in }; }; - # This service appears to have issues when system sleeps - restart service - systemd.user.services.mpd-discord-rpc-refresh = let - script = pkgs.writeShellScript "mpd-discord-rpc-refresh-script" + # MPDCRON to automate MPD related events, using it to automatically restart mpd-discord-rpc service to solve issues + systemd.user.services.mpdcron = let + script = pkgs.writeShellScript "mpdcron-script" '' - systemctl --user restart mpd-discord-rpc.service + mpdcron -n ''; in { Unit = { - Description = "Refresh mpd--discord-rpc service on sleep/hibernate/login to resolve issues"; - Before = [ "systemd-suspend.service" "systemd-hibernate.service" "systemd-hybrid-sleep.service" ]; - }; - Service = { - ExecStart = "${script}"; - }; - Install = { - WantedBy = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" "xdg-desktop-autostart.target" ]; - }; - }; - - systemd.user.services.mpd-discord-rpc-start = let - script = pkgs.writeShellScript "mpd-discord-rpc-start-script" - '' - systemctl --user start mpd.service - ''; - in - { - Unit = { - Description = "Start MPD on boot"; + Description = "Start MPDCRON on boot"; }; Service = { ExecStart = "${script}"; diff --git a/global-resources/home-manager/.mpdcron/hooks/player b/global-resources/home-manager/.mpdcron/hooks/player new file mode 100755 index 00000000..499bd0d6 --- /dev/null +++ b/global-resources/home-manager/.mpdcron/hooks/player @@ -0,0 +1,3 @@ +#!/bin/sh + +systemctl --user restart mpd-discord-rpc.service \ No newline at end of file diff --git a/global-resources/home-manager/.mpdcron/mpdcron.conf b/global-resources/home-manager/.mpdcron/mpdcron.conf new file mode 100644 index 00000000..f7b20d9b --- /dev/null +++ b/global-resources/home-manager/.mpdcron/mpdcron.conf @@ -0,0 +1,31 @@ +# mpdcron configuration file +[main] +# Path to the PID file, by default the PID file is MPDCRON_DIR/mpdcron.pid +# pidfile = /path/to/mpdcron.pid +# Wait this many seconds after sending signal to kill the daemon. +# Default is 3 seconds. +killwait = 3 +# Logging level, default is 0 +# 0: Warnings and errors only +# 1: Info and below +# 2: Debug and below +loglevel = 0 +[mpd] +# Semicolon delimited list of events to wait for. +# By default mpdcron waits for all events. +# Valid events are: +# database: Song database has been updated. +# stored_playlist: A stored playlist has been modified, created, +# deleted or renamed. +# playlist: The queue has been modified. +# player: The player state has been changed: play, stop, pause, seek, ... +# mixer: The volume has been modified. +# output: An audio output device has been enabled or disabled. +# options: Options have changed: crossfade, random, repeat, ... +# update: A database update has started or finished. +events = player +# Interval in seconds to reconnect to mpd after an error or disconnect. +reconnect = 5 +# Timeout in milliseconds for mpd timeout, 0 for default timeout of +# libmpdclient. +timeout = 0 \ No newline at end of file