You are not logged in.

#1 2026-06-08 10:42:20

bivan
Member
Registered: 2026-02-03
Posts: 33

How to launch Konsole with a pre-written command?

It's possible to click a script: Konsole launches prompting the argument(s), e.g. to install package(s):

#!/bin/bash
cd
konsole -e bash -c 'read a
sudo pacman -Syu $a
sudo rm -r /tmp/a
bash'

then I write e.g.

zaz chromium-bsu

But the title: I click something, Konsole launches with already written e.g.

sudo pacman -Syu 

?

The goal is to avoid writing or copy-pasting e.g. sudo pacman -Syu , a simple click.

Last edited by bivan (2026-06-08 18:52:31)

Offline

#2 2026-06-08 11:56:53

SimonJ
Member
From: Spain
Registered: 2021-05-11
Posts: 325
Website

Re: How to launch Konsole with a pre-written command?

This will do what you wanted, but I am not sure why you want it?

#!/bin/bash
cd
konsole -e bash -c 'read a; sudo pacman -Syu $a;tail -f /dev/null'

Rlu: 222126

Offline

#3 2026-06-08 13:56:05

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: How to launch Konsole with a pre-written command?

It seems the OP tries to drop into an interactive shell?
In that case this will have to be done in the bashrc - either a custom one (passed to bash) or eg. controlled by an environment that can be set w/ invoking the specific konsole instance.

Offline

#4 2026-06-08 18:45:44

bivan
Member
Registered: 2026-02-03
Posts: 33

Re: How to launch Konsole with a pre-written command?

I edited my 1st post, more clear.

Offline

#5 2026-06-08 19:28:53

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: How to launch Konsole with a pre-written command?

Sorta, but I guess you're looking for https://man.archlinux.org/man/rlwrap.1#P, ?

Last edited by seth (2026-06-08 19:29:10)

Offline

#6 2026-06-08 20:04:21

bivan
Member
Registered: 2026-02-03
Posts: 33

Re: How to launch Konsole with a pre-written command?

#!/bin/bash
cd
rlwrap -P 'sudo pacman -Syu ' konsole

this script launches Konsole normally, nothing pre-written, no.

So a package (other than rlwrap) would work? But not created?
Or a new Konsole option?

Last edited by bivan (2026-06-08 20:09:16)

Offline

#7 2026-06-08 20:24:07

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: How to launch Konsole with a pre-written command?

You run konsole w/ "rlwrap -P whatever bash", rlwrap'ping konsole makes no sense at all.

Offline

#8 2026-06-08 20:27:37

SimonJ
Member
From: Spain
Registered: 2021-05-11
Posts: 325
Website

Re: How to launch Konsole with a pre-written command?

If you are going to click something, open konsole, then alias something to  echo 'pacman -Syu' and add the package names, you still only click once and only type their names once.

Otherwise you are just making it difficult to achieve something you will do all the time.


Rlu: 222126

Offline

#9 2026-06-08 20:43:06

bivan
Member
Registered: 2026-02-03
Posts: 33

Re: How to launch Konsole with a pre-written command?

#!/bin/bash
cd
konsole -e rlwrap -P 'sudo pacman -Syu ' bash

it works at 1st impression, but then if I write e.g. zaz chromium-bsu , it's messed, the letters:

z chromium-bsu2f-4817-81fa-c5eb880b82af ~]$ sudo pacman -Syu za

Last edited by bivan (2026-06-08 21:01:15)

Offline

#10 2026-06-08 20:54:18

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: How to launch Konsole with a pre-written command?

it's messed, the letters.

https://deepl.com/translate
Or maybe link a screenshot.
rlwrap will inevitably have *some* impact here (notably the ctrl+c behavior and tab completion)

Also why are you posting some bash script?
You can just run

konsole -e rlwrap -P 'sudo pacman -Syu ' bash

Also please elaborate what exactly you're trying to achieve here - why is your OP approach to read the packages you're going to install and then pass them to pacman -Syu not desirable?
What's the purpose of all of this itfp? Why do you want to launch some special konsole instead of just entering "pacman -Syu whatever"?

Offline

#11 2026-06-08 21:06:38

bivan
Member
Registered: 2026-02-03
Posts: 33

Re: How to launch Konsole with a pre-written command?

I edited my previous post.

Is it a rlwrap bug? Should I report?

Yes my OP approach works, I just wonder if the title is possible, more pure, I'm lazy to write "sudo pacman -Syu ".

Offline

#12 2026-06-08 21:09:43

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: How to launch Konsole with a pre-written command?

Do you get this w/

konsole -e rlwrap -P 'sudo pacman -Syu ' bash --norc

or

xterm -e rlwrap -P 'sudo pacman -Syu ' bash --norc

?

Edit: how wide is your terminal? Do you expect the input to wrap where it rewinds?
rlwrap isn't exactly written to wrap an interactive shell - it's to provide readline features to "dumb" processes.

Last edited by seth (2026-06-08 21:14:50)

Offline

#13 2026-06-08 21:25:21

bivan
Member
Registered: 2026-02-03
Posts: 33

Re: How to launch Konsole with a pre-written command?

The 1st: yes, but I write zaz chromium-bsu then press Enter: the text appears glitched (need a video here, or why not you try yourself?).

The 2nd: I haven't xterm, why xterm?

Edit: 1920*1080 display, I unchecked Konsole, Remember window size, no, there's space for all the command.

Last edited by bivan (2026-06-08 21:31:50)

Offline

#14 2026-06-08 23:45:59

bivan
Member
Registered: 2026-02-03
Posts: 33

Re: How to launch Konsole with a pre-written command?

Thanks to Gemini:
Configure Konsole..., Enable the security sensitive parts of the DBus API

#!/bin/bash
cd
if ! pgrep -x konsole
then konsole
fi
/usr/lib/qt6/bin/qdbus org.kde.konsole /Sessions/1 org.kde.konsole.Session.sendText 'sudo pacman -Syu '

theorically it should work: if Konsole runs: ok but if not: there isn't "sudo pacman -Syu ", despite "sleep 1" between "then konsole" & "fi", why?

Last edited by bivan (2026-06-08 23:51:53)

Offline

#15 Yesterday 06:40:43

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: How to launch Konsole with a pre-written command?

or why not you try yourself? why xterm?

Because I don't have and won't install KDE and this doesn't happen w/ other TEs

theorically it should work: if Konsole runs: ok but if not: there isn't "sudo pacman -Syu ", despite "sleep 1" between "then konsole" & "fi", why?

Because that script is sketchy and relies on various assumptions - afair konsole injects its bus into the environment so you can just "konsole -e env PRESET_PACMAN=true bash" and in your bashrc

if $PRESET_PACMAN; then qdbus6 $KONSOLE_DBUS org.kde.konsole.Session.sendText 'sudo pacman -Syu '; fi

KONSOLE_DBUS is a placeholder, check "printenv" to find the actual variable.

Offline

#16 Yesterday 11:18:58

bivan
Member
Registered: 2026-02-03
Posts: 33

Re: How to launch Konsole with a pre-written command?

omg I discovered a strange issue answering the why, e.g.

#!/bin/bash
cd
konsole
dolphin

only Konsole launches! Then if I close it, Dolphin launches! wtf, how to launch both?

Last edited by bivan (Yesterday 11:27:04)

Offline

#17 Yesterday 11:38:16

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

Re: How to launch Konsole with a pre-written command?

That is expected as bash executes commands sequentially : once a command finishes it starts the next command.

There is  a method to tell bash NOT to wait until a command has finished but immediately run the next one . The technique is called backgrounding, see https://web.archive.org/web/20160616013 … -properly/ .

Note that backgrounded commans will not be stopped when the bash script that started them finishes .


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

#18 Yesterday 12:10:22

bivan
Member
Registered: 2026-02-03
Posts: 33

Re: How to launch Konsole with a pre-written command?

Thanks (but web.archive.org ? There isn't a regular web site, as https://wiki.archlinux.org/ ?), a working script:

#!/bin/bash
cd
if ! pgrep -x konsole
then konsole &
sleep 0.2
fi
qdbus6 $(qdbus6|grep konsole) /Sessions/1 org.kde.konsole.Session.sendText 'sudo pacman -Syu '

sleep 0.1 is too short
$(qdbus6|grep konsole) instead of org.kde.konsole as before because seems since I did "konsole &",

qdbus6|grep konsole

gives like org.kde.konsole-733471 , org.kde.konsole-733604 ... why?

Offline

#19 Yesterday 12:15:53

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: How to launch Konsole with a pre-written command?

felixmilea.comis 404 and there're countless bash tutorials, https://ryanstutorials.net/bash-scripting-tutorial/
What do you think the parameterless "cd" does?
Also, again: stop this nonsense.
Check the output of "printenv", there'll be some variables specific to konsole.
You'll use those in the bashrc - grepping for random konsole interfaces will not at all guarantee what you're trying to do.

Offline

#20 Yesterday 12:31:40

bivan
Member
Registered: 2026-02-03
Posts: 33

Re: How to launch Konsole with a pre-written command?

cd because if no: it's the script's directory.

This script works, so why editing bashrc? Now I just wonder why it's org.kde.konsole-some_number , only org.kde.konsole before.

Offline

#21 Yesterday 12:43:32

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 75,838

Re: How to launch Konsole with a pre-written command?

cd because

Don't rely on interactive shortcuts, if you want to enter $HOME, cd $HOME

This script works

gives like org.kde.konsole-733471 , org.kde.konsole-733604 ... why?

there isn't "sudo pacman -Syu ", despite "sleep 1"

Because the script "works" (or not) based on wild assumptions about the context that are not necessarily true.

Offline

Board footer

Powered by FluxBB