Switch to mpdcron to fix mpd-discord-rpc service related issues
This commit is contained in:
parent
9dbe998f0d
commit
48039d26e6
|
|
@ -79,8 +79,6 @@
|
||||||
Group = "root";
|
Group = "root";
|
||||||
};
|
};
|
||||||
script = "
|
script = "
|
||||||
# This service appears to have issues when system sleeps - stop service
|
|
||||||
systemctl -M 'cspark@' --user stop mpd-discord-rpc.service
|
|
||||||
# Unbind audio interface
|
# Unbind audio interface
|
||||||
echo `grep 0a73 /sys/bus/usb/devices/*/idVendor | cut -d '/' -f 6` > /sys/bus/usb/drivers/usb/unbind
|
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
|
# Remove snd_usb_audio once no longer in use
|
||||||
|
|
@ -104,8 +102,6 @@
|
||||||
modprobe snd_usb_audio
|
modprobe snd_usb_audio
|
||||||
# Rebind audio interface
|
# Rebind audio interface
|
||||||
echo `grep 0a73 /sys/bus/usb/devices/*/idVendor | cut -d '/' -f 6` > /sys/bus/usb/drivers/usb/bind
|
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
|
|
||||||
";
|
";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ in
|
||||||
kdenlive
|
kdenlive
|
||||||
vlc
|
vlc
|
||||||
|
|
||||||
|
mpdcron
|
||||||
|
|
||||||
pass-wayland
|
pass-wayland
|
||||||
thunderbird
|
thunderbird
|
||||||
|
|
||||||
|
|
@ -72,6 +74,35 @@ in
|
||||||
libnotify
|
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
|
# Have to enable the mpd and mpd-discord-rpc user services manually for now
|
||||||
services.mpd = {
|
services.mpd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
@ -135,35 +166,16 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# This service appears to have issues when system sleeps - restart service
|
# MPDCRON to automate MPD related events, using it to automatically restart mpd-discord-rpc service to solve issues
|
||||||
systemd.user.services.mpd-discord-rpc-refresh = let
|
systemd.user.services.mpdcron = let
|
||||||
script = pkgs.writeShellScript "mpd-discord-rpc-refresh-script"
|
script = pkgs.writeShellScript "mpdcron-script"
|
||||||
''
|
''
|
||||||
systemctl --user restart mpd-discord-rpc.service
|
mpdcron -n
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Refresh mpd--discord-rpc service on sleep/hibernate/login to resolve issues";
|
Description = "Start MPDCRON on boot";
|
||||||
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";
|
|
||||||
};
|
};
|
||||||
Service = {
|
Service = {
|
||||||
ExecStart = "${script}";
|
ExecStart = "${script}";
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
systemctl --user restart mpd-discord-rpc.service
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in New Issue