From 6fdfd6b022613419c7dad2a009574cbdd331b09a Mon Sep 17 00:00:00 2001 From: kevinlekiller Date: Mon, 24 Jun 2019 13:58:40 -0400 Subject: [PATCH 1/3] This assures the X server is started. The systemd service would not start because the wrong target was used and the X server would start after the grabber started. --- hgx11.service | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/hgx11.service b/hgx11.service index fa7e082..c79dff4 100644 --- a/hgx11.service +++ b/hgx11.service @@ -1,18 +1,16 @@ +# ~/.config/systemd/user/hgx11.service +# systemctl --user enable hgx11.service && systemctl --user start hgx11.service [Unit] Description=Starts Hyperion_Grabber_X11_QT. After=graphical.target After=network.target -[Service] +[Service] +Environment="DISPLAY=:0" +ExecStartPre=/usr/bin/bash -c "while ! xset q &> /dev/null; do sleep 1; done" ExecStart=/usr/local/sbin/Hyperion_Grabber_X11_QT --address 192.168.2.213 --port 19444 --frameskip 1 --scale 48 --inactive 600 --redadjust "255,10,0" --greenadjust "75,210,0" --blueadjust "0,10,160" Restart=always RestartSec=10 -# There seems to be a bug in systemd user services where it doesn't wait for he ExecStart process to end so this is a hacky workaround -# https://superuser.com/questions/1450650/wait-for-user-service-to-gracefully-exit-before-machine-shutdown-reboot -TimeoutStopSec=5 -ExecStop=/usr/bin/hyperion-remote -a 192.168.2.213:19444 -c 000000 -ExecStopPost=/usr/bin/hyperion-remote -a 192.168.2.213:19444 -c 000000 - [Install] -WantedBy=multi-user.target +WantedBy=default.target From fc96668609a958d4ffc9bb4222c553cd6b5f5e38 Mon Sep 17 00:00:00 2001 From: kevinlekiller Date: Mon, 24 Jun 2019 14:02:30 -0400 Subject: [PATCH 2/3] This systemd system service clears the LED's The systemd user service might not clear the LED's because systemd doesn't allow enough time for the grabber to gracefully shutdown, so this service ensures the LED's do turn off, unfortunately this doesn't occur on user logout, putting a ExecStop in the user script could also be a viable option. --- hgx11stop.service | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 hgx11stop.service diff --git a/hgx11stop.service b/hgx11stop.service new file mode 100644 index 0000000..1752e18 --- /dev/null +++ b/hgx11stop.service @@ -0,0 +1,12 @@ +# /etc/systemd/system/hgx11stop.service +# systemctl enable hgx11stop.service && systemctl start hgx11stop.service +[Unit] +Description=Clears hyperion LED's on shutdown. + +[Service] +ExecStart=/usr/bin/echo 1 +RemainAfterExit=1 +ExecStop=/usr/bin/hyperion-remote -a 192.168.2.213:19444 -c 000000 + +[Install] +WantedBy=multi-user.target From d6c269b1b36ee4dfa642f7b54de4ffb5498d84fa Mon Sep 17 00:00:00 2001 From: kevinlekiller Date: Mon, 24 Jun 2019 14:04:09 -0400 Subject: [PATCH 3/3] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 029e702..4e41868 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,10 @@ Example usage: `Hyperion_Grabber_X11_QT --address 192.168.2.213 --port 19444 --f `hgx11.service` is included as an example if you wish to use a systemd service to start the grabber on login. Edit it to set your options. -You would copy it to `~/.config/systemd/user/` and enable it with `systemctl --user enable hypergrabx11.service`, -to start it run `systemctl --user enable hypergrabx11.service`. +You would copy it to `~/.config/systemd/user/` and enable it with `systemctl --user enable hgx11.service`, +to start it run `systemctl --user enable hgx11.service`. + +`hgx11stop.service` ensures the LED's are cleared on shutdown, edit it and put it in `/etc/systemd/system/` ## Info