You are not logged in.

#1 2021-11-28 10:26:22

sebastian-65
Member
Registered: 2021-11-08
Posts: 40

[SOLVED] How to run script as root at GUI startup

Even though I've read about Autostarting  and XFCE autostart, I'm still confused how to solve my scenario:

When I log into desktop environment, I need my script to switch java to older version (which requires root permission), and then start an application (no root required), and then revert java back to newer version again.

How this should be achieved in the right way? Shall I create a systemd service just for this?

Thank you for clarification.

Last edited by sebastian-65 (2021-11-28 17:52:55)


I'm not the sharpest tool in the shed. Say it to me like I'm 5, please!

Arch Linux | ZFS | systemd | Xfce/X11/SDDM | ASUS S435 | Intel CPU 11th gen | Intel TigerLake-LP GT2 | 16GB RAM

Offline

#2 2021-11-28 10:39:54

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] How to run script as root at GUI startup

Not sure about the "right" way but you could just use sudo to switch the Java version and add a NOPASSWD exception for that command in /etc/sudoers{,.d/}.

You might get better advice if you share the exact script and your attempts so far.


Jin, Jîyan, Azadî

Offline

#3 2021-11-28 12:37:48

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,311

Re: [SOLVED] How to run script as root at GUI startup

https://wiki.archlinux.org/title/Java#L … va_version

That method may allow you to run the apllication with it's preferred java version without needing root rights.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#4 2021-11-28 17:52:37

sebastian-65
Member
Registered: 2021-11-08
Posts: 40

Re: [SOLVED] How to run script as root at GUI startup

That's clever. Thank you, that did help me solve this scenario.


I'm not the sharpest tool in the shed. Say it to me like I'm 5, please!

Arch Linux | ZFS | systemd | Xfce/X11/SDDM | ASUS S435 | Intel CPU 11th gen | Intel TigerLake-LP GT2 | 16GB RAM

Offline

Board footer

Powered by FluxBB