Konsole (and others) starts in root dir?

Terminals i tried this with: st, konsole

So i’m on a fresh install of KDE on Gentoo, and when i launch a terminal using a keyboard shortcut, the cwd is set to / by default. When i launch it from the menu or any other way though, it launches in ~ like normal. Why?

It could be the working directory on your plasmashell instance. You can check by running ls -l /proc/$(pidof plasmashell)/cwd

If your Plasma is using systemd integration (as it should), then it should be fine because the default WorkingDirectory setting for user services is the user’s home directory - but maybe you have a specific setting in your systemd service file (or override).

Well, i’m running OpenRC, but i checked anyway, and it seems that that directory is a symlink to my home dir, so that doesn’t seem to be what the problem is :woman_shrugging:

The current working directory for a new Konsole instance is set by either:

  1. the current working directory from where it was started
  2. the profile selected (or the default profile)
  3. or a command line argument.

If its not (1), it could be one of the others. I don’t believe it is either (2) or (3) because the way that the default Konsole global shortcut (CTRL+ALT+T) works is by setting it on the launcher in the main application launcher menu (kickoff) - so when you start Konsole from the app launcher, you’re supposed to get the same behavior - because it uses the same command line and whatever non-default profile or non-default working directory set in the launcher, would be the same for both launching from the standard global shortcut as well as from the application launcher.

I don’t think it is 2. or 3. since this affects st too.

Possibly this is because of OpenRC?
If I understand this correctly the cwd is inherited from the parent process.
When I start konsole from krunner it inherits the cwd from krunner(parent process) which is ~
When I start konsole using a keyboardshortcut its parent process is sytemd (cwd is /) but it sets it correctly somehow?

Maybe that’s the case, but what do i do about it? I guess that’s outside the wheelhouse of this forum and i should ask elsewhere?

For now I asked on the Gentoo Matrix channel if someone using KDE and OpenRC can reproduce this. Maybe we get lucky and someone can either confirm or deny my idea that this is about OpenRC. Then we can go from there.

You can ofc also ask elsewhere. Just keep checking here once in a while. Maybe @guss77 or someone else has more ideas.

1 Like

So I use Gentoo Openrc as well, but I dont see this behavior.

But I tried starting kde when my pwd was / and seeing what happens.

$ ls -l /proc/$(pidof plasmashell)/cwd
lrwxrwxrwx 1 ask ask 0 Aug 29 20:13 /proc/4629/cwd -> /

So for me konsole only initialised with / when started from the startmenu. Otherwise it had ~ when started from krunner or the global shortcut.

1 Like

What is happening???

It should be noted that i use SDDM rather than launching from the tty, so maybe it’s a SDDM problem??

I use SDDM as well. So plausibly version or configuration specific. sddm-0.20.0 here with no extra configuration other than starting it normally with the display-manager init script.

@yabobay a friendly user on the gentoo matrix channel had the same issue with konsole.
They fixed the issue like this:


That made me checkout ~/.config/konsolerc and “DefaultProfile” was set to “Profile 4”
Manually setting it to “1” and c+a+T’ing again does show up with “~” now

Not sure if it is the same issue since you can also reproduce with other terminals but its worth a try.

I did change a setting in Konsole to make it start in ~/, but that still leaves other programs (in the meantime i also observed Emacs has this problem)

Do you use X or Wayland? Does your SDDM run rootless? Can you post your SDDM conf?

I use X, my SDDM is running as root, and here it is:

[Autologin]
# Whether sddm should automatically log back into sessions when they exit
Relogin=false

# Name of session file for autologin session (if empty try last logged in)
Session=

# Username for autologin session
User=


[General]
# Halt command
HaltCommand=/usr/bin/loginctl poweroff

# Input method module
InputMethod=

# Comma-separated list of Linux namespaces for user session to enter
Namespaces=

# Initial NumLock state. Can be on, off or none.
# If property is set to none, numlock won't be changed
# NOTE: Currently ignored if autologin is enabled.
Numlock=none

# Reboot command
RebootCommand=/usr/bin/loginctl reboot


[Theme]
# Current theme name
Current=

# Cursor theme used in the greeter
CursorTheme=

# Number of users to use as threshold
# above which avatars are disabled
# unless explicitly enabled with EnableAvatars
DisableAvatarsThreshold=7

# Enable display of custom user avatars
EnableAvatars=true

# Global directory for user avatars
# The files should be named <username>.face.icon
FacesDir=/usr/share/sddm/faces

# Theme directory path
ThemeDir=/usr/share/sddm/themes


[Users]
# Default $PATH for logged in users
DefaultPath=/usr/local/bin:/usr/bin:/bin

# Comma-separated list of shells.
# Users with these shells as their default won't be listed
HideShells=

# Comma-separated list of users that should not be listed
HideUsers=

# Maximum user id for displayed users
MaximumUid=60000

# Minimum user id for displayed users
MinimumUid=1000

# Remember the session of the last successfully logged in user
RememberLastSession=true

# Remember the last successfully logged in user
RememberLastUser=true

# When logging in as the same user twice, restore the original session, rather than create a new one
ReuseSession=true


[Wayland]
# Enable Qt's automatic high-DPI scaling
EnableHiDPI=true

# Path to a script to execute when starting the desktop session
SessionCommand=/usr/share/sddm/scripts/wayland-session

# Directory containing available Wayland sessions
SessionDir=/usr/share/wayland-sessions

# Path to the user session log file
SessionLogFile=.local/share/sddm/wayland-session.log


[X11]
# Path to a script to execute when starting the display server
DisplayCommand=/usr/share/sddm/scripts/Xsetup

# Path to a script to execute when stopping the display server
DisplayStopCommand=/usr/share/sddm/scripts/Xstop

# Enable Qt's automatic high-DPI scaling
EnableHiDPI=true

# The lowest virtual terminal number that will be used.
MinimumVT=7

# Arguments passed to the X server invocation
ServerArguments=-nolisten tcp

# Path to X server binary
ServerPath=/usr/bin/X

# Path to a script to execute when starting the desktop session
SessionCommand=/usr/share/sddm/scripts/Xsession

# Directory containing available X sessions
SessionDir=/usr/share/xsessions

# Path to the user session log file
SessionLogFile=.local/share/sddm/xorg-session.log

# Path to the Xauthority file
UserAuthFile=.Xauthority

# Path to xauth binary
XauthPath=/usr/bin/xauth

# Path to Xephyr binary
XephyrPath=/usr/bin/Xephyr

On Arch possible since 0.20.0. or when compiling from source. (Fedora had it a default for a while I think)

For reference how to do it on Arch: SDDM - ArchWiki
Might be different on Gentoo.

Still only a wild guess but maybe this is your issue :wink:

I tried setting it to rootless xorg, still the same problem happening :confused:

Alright, X11 KDE started from SDDM gets this issue. I was previously using Wayland or X11 started outside of sddm.

DisplayServer set to x11 or x11-user make no change to this.

So i’m gonna have to switch to wayland? Bummer, time to enable the use flag and recompile all the things

Especially since i use nvidia

I use a “pre-startup” script to set DE-wide stuff. I wonder if a change directory there would be a workaround.

It shows in system settings, autostart, but I have to create the script in ~/.config/plasma-workspace/env. Be aware that it is run using dash, regardless of shebang, and failure might stop the DE starting.

That’s a good idea, but i think i’ll just stop using sddm since i’m not really gaining anything from it.