Forum / NoMachine for Linux / Help needed with custom scripts for XFCE desktop start/stop in NoMachine
- This topic has 10 replies, 4 voices, and was last updated 3 months, 2 weeks ago by Britgirl.
-
AuthorPosts
-
August 22, 2024 at 13:43 #49299RunAway189Participant
Hello everyone,
I’ve installed NoMachine on my Debian server, which uses XFCE as the desktop environment. To simulate a real desktop environment at 1080p, I’m using an EDID emulator, and everything is working perfectly. My N100 is leveraging hardware decoding, and the performance is as expected.
However, I’m having trouble with automatically starting and stopping the desktop environment (lightdm.service) based on my NoMachine session. My goal is to start lightdm when I connect to the server and stop it when I close my session (by simply pressing ‘x’ on the window), using the node.cfg file.
Here’s what I’ve done so far:
- Created two scripts in
/usr/NX/scripts/custom/
:start_de.sh
for starting the desktop environment.stop_de.sh
for stopping the desktop environment.
- Updated the
node.cfg
file with the following lines:UserScriptBeforeSessionStart /usr/NX/scripts/custom/start_de.shUserScriptBeforeSessionStart /usr/NX/scripts/custom/stop_de.sh
Despite these configurations, the desktop environment does not start or stop as expected.
Can anyone help me troubleshoot what might be going wrong or provide guidance on achieving this setup?
Thank you in advance for your assistance!
August 23, 2024 at 16:55 #49344BritgirlKeymasterHi, I’m not sure what you’d like to achieve in terms of running the LDM after the XFCE desktop session starts. Maybe try with #UserScriptAfterLogin “” and in the server.cfg, not node.cfg? Also check your permissions, and ownership of the effective user. This ‘afterlogin’ script is executed as user nx, so you need admin privileges.
More about custom scripts is available here:
Server Automation Interface: some examples to use custom scripts triggered on server/node events
https://kb.nomachine.com/AR02L00787and any of the guides of the Enterprise products. Here’s the link to the Enterprise Desktop guide (like the free version but with more features) https://kb.nomachine.com/DT10R00171#11.3.
August 26, 2024 at 14:38 #49363RunAway189ParticipantThanks for your response, @Britgirl. My main goal is to conserve resources when I’m not using the GUI on my Debian server. Specifically, I want to ensure that when I disconnect from the NoMachine client, the Desktop Environment “shuts down” while keeping the rest of the server running.
Is my understanding correct? Should I focus on the
UserScriptAfterLogin
inserver.cfg
to achieve this, and ensure proper permissions and ownership for the usernx
?Thanks for the helpful links as well!
August 26, 2024 at 18:56 #49378RunAway189ParticipantI’ve specified my scripts in server.cfg file like you suggested me but the only way to make them working is editing sudoers file with:
nx ALL=(ALL) NOPASSWD: ALL
But honestly I’d prefer something else since this is very unsafe. I’m waiting for some suggestion. Thanks to everyone!
August 28, 2024 at 16:16 #49427hawkParticipantHello,
You can limit rule for nx user to run only specific commands.
Try to replace:
nx ALL=(ALL) NOPASSWD: ALL
to:
nx ALL=(ALL) NOPASSWD: /usr/NX/scripts/custom/start_de.sh, /usr/NX/scripts/custom/stop_de.sh
Please inform if this worked and if this is satisfying enough.
August 28, 2024 at 17:38 #49434RunAway189ParticipantThanks for your reply @hawk, I’ve just tried what you suggested but unfortunately it doesn’t work: it’s asking me for nx password to execute the script. (I’m manually testing it through ‘sudo -u nx /usr/NX/scripts/custom/start_de.sh’)
August 28, 2024 at 18:29 #49438BilbotineParticipantHi RunAway189,
Then let’s try something else, if you agree: could you send us the two scripts you mentioned earlier ( Start_de.sh and stop_de.sh ) , by email ?
You can send them to forum[at]nomachine[dot]com, making sure to reference the topic as the subject of the email.
Thank you!
September 6, 2024 at 15:37 #49567BritgirlKeymasterTry this instead
nx ALL=(ALL) NOPASSWD: /usr/bin/systemctl start lightdm.service, /usr/bin/systemctl stop lightdm.service
We tested on our Debian with XFCE. Nx will have permission to execute sudo without password but only to start/stop lightdm service.
September 6, 2024 at 17:05 #49569RunAway189ParticipantThanks a lot for the reply again, so this is the bash script I should run or is it just the visudo file I need to edit? Sorry, I just want to make sure that everything is set properly. @Britgirl
September 7, 2024 at 13:51 #49573RunAway189ParticipantFinally with your new suggested settings I’ve been able to automate my lightdm service. Thanks everyone for the fantastic support, you’re great!
September 9, 2024 at 08:38 #49580BritgirlKeymasterYes, visudo.
- Created two scripts in
-
AuthorPosts
This topic was marked as solved, you can't post.