![]() Registered Member ![]()
|
How to start kate or dolphin within a bash script ?
I need to start two bash script from two desktop links. a) The first one ( say script_a ) need to start kate as root user to edit 18 small scripts or config files. b) The second one ( say script_b ) as root user, run a master script that call 18 small scripts. Some of these scripts sometimes may need to start kate for editing some config file when a parameter is missing or wrong. I need to run in console to see the warnings. I have try to put
I have try to start the scripts with "kdesu /path/to/the/script_file" in the .desktop files but got errors. For now, the .desktop files are configured to be started as root, run in konsole, and dbus registration is set to "run until finished"
Below are logs from the konsole
Below is output of :
Below is output of :
Any help is welcome. |
![]() Registered Member ![]()
|
Hi!
Your approach using kdesu was a good one. If you want to start it with a .desktop-file you would have to open a separate shell. Example:
wich will open kate in "background". Using a desktop-file would look like "Exec=/bin/bash -c '/path/to/script.sh'" or "Exec=/bin/bash -c '/usr/bin/kdesu /usr/bin/kate /etc/fstab' |
![]() Registered Member ![]()
|
I shall give news as soon as possible |
![]() Registered Member ![]()
|
I use a parameter when calling kate ( list of file to edit ).
It seems that parameter length is limited to about 4105 characters. See https://forums.opensuse.org/showthread.php/524242-bash-script-parameter-max-size-lengthg?p=2819290#post2819290 for details. Any help is welcome. |
![]() Registered Member ![]()
|
https://forums.opensuse.org/showthread.php/524242-bash-script-parameter-max-size-lengthg
Removing kdesu, kate start normally and all files are present. Any help is welcome. |
![]() Registered Member ![]()
|
Is it possible to workaround this size creating an temporary file?
e.g.:
Can you provide an example how it finally should work? |
![]() Registered Member ![]()
|
When I hear about max command/parameter lengths in bash, my first instincts are to suggest using xargs to call your command on each item rather than passing all of them together to the next command. In this case, it would probably be easier to loop over the files and run the command to open kate on them individually. Both of these suggestions assume that running: kate /path/to/some/file when kate is already running (for some user) will open the file in a new tab in the running kate instance. The main difference being: are the file names piped in from some other command/file (use xargs), or are they specified as a glob or variable in the script (use for loop).
or one-liners for desktop files: for loop: Exec=/bin/bash -c 'for f in /path/to/files/*; do /usr/bin/kdesu /usr/bin/kate $f & done' xargs: Exec=/bin/bash -c 'command which outputs filenames | xargs kdesu /usr/bin/kate' of course your command which outputs filenames could be: echo /my/list /of/files ...
airdrik, proud to be a member of KDE forums since 2008-Dec.
|
![]() Registered Member ![]()
|
Kate no longer starts as root. For your first script, you should probably use sudoedit instead. For your second, you'll need to think of a different situation.
|
![]() Registered Member ![]()
|
That is KDE Applications 17.04 : https://www.kde.org/announcements/fulll ... .04.0#kate -> https://cgit.kde.org/kate.git/commit/?i ... 46b0e12a7e
but with the KDE Frameworks 5.34 or later the password is requested if needed. No need to start the kate/kwrite with the root rights: https://phabricator.kde.org/D4847 & https://phabricator.kde.org/D5394
![]() |
![]() Registered Member ![]()
|
-Create an application launcher (desktop file) then select your script : /home/some_user/bin/my_kate_launcher.sh -Choose run in terminal (to see errors) -Choose do not close when command exits (to see errors) -Choose run as different user : root Here the script :
I am running opensuse leap 42.2, KDE Frameworks: 5.26.0 |
![]() Registered Member ![]()
|
Have try the loop version. For every files, open a new instance of kate and ask for the root password This is not interesting. I think my solution better. |
![]() Registered Member ![]()
|
Seems to open the file in /tmp but save the modified file also in /tmp |
![]() Registered Member ![]()
|
to average Joe, these 2 cases are the same thing. ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Registered users: Bing [Bot], Evergrowing, Google [Bot], q.ignora, watchstar