Help needed with custom scripts for XFCE desktop start/stop in NoMachine

Forum / NoMachine for Linux / Help needed with custom scripts for XFCE desktop start/stop in NoMachine

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #49299
    RunAway189
    Participant

    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:

    1. Created two scripts in /usr/NX/scripts/custom/:
      • start_de.sh for starting the desktop environment.
      • stop_de.sh for stopping the desktop environment.
    2. 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!

     

    #49344
    Britgirl
    Keymaster

    Hi, 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/AR02L00787

    and 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.

    #49363
    RunAway189
    Participant

    Thanks 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 in server.cfg to achieve this, and ensure proper permissions and ownership for the user nx?

    Thanks for the helpful links as well!

     

    #49378
    RunAway189
    Participant

    I’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!

    #49427
    hawk
    Participant

    Hello,

    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.

    #49434
    RunAway189
    Participant

    Thanks 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’)

    #49438
    Bilbotine
    Participant

    Hi 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!

    #49567
    Britgirl
    Keymaster

    Try 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.

    #49569
    RunAway189
    Participant

    Thanks 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

    #49573
    RunAway189
    Participant

    Finally with your new suggested settings I’ve been able to automate my lightdm service. Thanks everyone for the fantastic support, you’re great!

     

    #49580
    Britgirl
    Keymaster

    Yes, visudo.

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Please login .