KDE 4.11.5 - Application Launcher (Kickoff)

hello.
I use many script like this one :

#!/bin/bash
#
########################
#
#   /usr/local/bin/some_script
#
########################
#
# COMMENT
#
########################
#
kate --startanon  file1 file2 ....

Some of file1 file2 …, need to be open under root account like /var/log/messages

So I used to open a terminal in super user mode, type root password, and start my script.

I have added a sub-menu using the “KDE MENU EDITOR” and added an item for my script. In the command argument I have tried unsuccessfully :
1°) xdg-su -c /usr/local/bin/some_script
2°) kdesu /usr/local/bin/some_script
3°) $(kde4-config --path libexec)kdesu /usr/local/bin/some_script

Any help is welcome

As soon as this will be fixed, I shall add some items under the root account.
How to inherit this modification in the Kickoff Apps menu for all the users without to re-edit the system menu for all users.

Any help is welcome

I haven’t tried any of those. I suspect the problem is that your script is not a GUI application, so even if the script runs you won’t see any output.

Try something like:


kdesu xterm -e /usr/local/bin/some_script

That would provide a terminal window and run the script in that window. Note that I have not tested this.

Or just set the script as command, and enable “Run as different user” and “Run in a terminal” on the “Advanced” tab.

The menu entries are stored in ~/.local/share/applications/, the sub-directories in ~/.local/share/desktop-directories/, and the menu structure in ~/.config/menu/.
So copy those folders to your other user accounts.

To create a menu entry system-wide, you would have to put a corresponding .desktop file into /usr/share/applications/, sub-directories are in /usr/share/desktop-directories/ accordingly, and the menu structure is defined in /etc/xdg/menus/ (but you shouldn’t change the latter probably :wink: ).

In the command line option of “KDE MENU EDITOR” :

kdesu xterm -e /usr/local/bin/some_script

Not working.

kdesu xterm

Open a window and if I start the script manually, it starts.

If I write a new script “/usr/local/bin/some_script_launcher” and in that script I put :

xterm -e /usr/local/bin/some_script

and In the command line option of “KDE MENU EDITOR” :

kdesu /usr/local/bin/some_script_launcher

Not working

In /var/log/messages I got :

§TIME§ Sep  5 16:50:54,§PR§ 5,§FCLTY§ 4,§HOST§ LINUX-TEST-123, §TAG§  su:, §MSG§  { (to tux_user) tux_user on none} 

§TIME§ Sep  5 16:50:54,§PR§ 6,§FCLTY§ 10,§HOST§ LINUX-TEST-123, §TAG§  su:, §MSG§  { pam_unix(su:session): session opened for user root by (uid=1000)} 

§TIME§ Sep  5 16:50:54,§PR§ 3,§FCLTY§ 10,§HOST§ LINUX-TEST-123, §TAG§  su:, §MSG§  { pam_systemd(su:session): pam_putenv: delete non-existent entry; XDG_RUNTIME_DIR}

Any idea ?

Not working.
Just a blank screen with passwd:
Keep blank after typing passwd.
Same kind of message in /var/log/messages

§TIME§ Sep  5 17:13:11,§PR§ 5,§FCLTY§ 4,§HOST§ LINUX-TEST-123, §TAG§  su:, §MSG§  { (to tux_user) tux_user on none} 

§TIME§ Sep  5 17:13:11,§PR§ 6,§FCLTY§ 10,§HOST§ LINUX-TEST-123, §TAG§  su:, §MSG§  { pam_unix(su:session): session opened for user root by tux_user(uid=1000)} 

§TIME§ Sep  5 17:13:11,§PR§ 3,§FCLTY§ 10,§HOST§ LINUX-TEST-123, §TAG§  su:, §MSG§  { pam_systemd(su:session): pam_putenv: delete non-existent entry; XDG_RUNTIME_DIR} 

§TIME§ Sep  5 17:13:12,§PR§ 6,§FCLTY§ 10,§HOST§ LINUX-TEST-123, §TAG§  su:, §MSG§  { pam_unix(su:session): session closed for user root} 


I will try when I make things working.

Putting

xterm

as command ( with or without option run in terminal ) works; but

xterm -e <script name>

does not

Well, then something is wrong with your script, obviously.
And that explains why the other ways are not working either.

Is the script actually marked as executable?
Can you run it manually in a terminal window?

If you are trying to handle password prompts in a script, that’s probably not going to work the way you want.

Perhaps look into an “expect” script for that.

To be as clear as possible

  1. All these scripts are scripts that I use for years.
  2. All the scripts run without errors
  3. Usually I open a “konsole window”, type su ( or open directly konsole in super user mode), type the root password, then I type the name of the script.
  4. Now I would like to put all of them in a “User Apps” sub-menu using kde menu editor.

I just want to starts all these scripts from a menu using my mouse.

If you look a my post #5, I can start a window from menu, and type the command, but I can’t do this in one action.
[LEFT]In addition, at a certain moment I need to be root user.

[/LEFT]

Well, “xterm -e scriptname” doesn’t work here either.
But “konsole -e -noclose scriptname” does.

Well if your script requires root permission you also need to invoke a GUI “sudo” Note there are several options. I note that dbus-launch is used a lot for root level GUI apps. I believe you can also use kdesudo or gnomesudo if in gnome. I beleive that dbus-launch is desktop agnostic.

But dbus-launch in itself does not run a program as root.

It creates a dbus session for that program/user if none is running, especially GUI apps might need that when you run them as a different user.
(a dbus session for the logged in user is automatically started during login, KDE e.g. wouldn’t work otherwise)
From the man-page:

      The dbus-launch command is used to start a session bus instance of
       dbus-daemon from a shell script. It would normally be called from a
       user's login scripts. Unlike the daemon itself, dbus-launch exits, so
       backticks or the $() construct can be used to read information from
       dbus-launch.
...
       You may specify a program to be run; in this case, dbus-launch will
       launch a session bus instance, set the appropriate environment
       variables so the specified program can find the bus, and then execute
       the specified program, with the specified arguments. See below for
       examples.

I believe you can also use kdesudo or gnomesudo if in gnome.

It’s “kdesu” and “gnomesu”… :wink:

“kdesudo” does exist as well, but it’s not part of KDE, rather a 3rdparty program, and not included in openSUSE at all.
It is shipped instead of “kdesu” in Kubuntu though AFAIK…

“gnome-sudo” does exist as well, but again is not part of a standard openSUSE GNOME installation.

Btw, kdesu normally uses “su” (it can be configured to use sudo instead), whereas “kdesudo” is a frontend to sudo as the name implies.
I think it’s similar for “gnomesu” and “gnome-sudo”.

I beleive that dbus-launch is desktop agnostic.

Well, yes, but as mentioned already it is something completely different.

A desktop-agnostic way to launch GUI applications as root would be “xdg-su”, which actually calls e.g. “kdesu” or “gnomesu” e.g. in turn depending whether it detects a running KDE or GNOME session.