Bug 406955 - Switching profile does not update KONSOLE_PROFILE_NAME environment variable
Summary: Switching profile does not update KONSOLE_PROFILE_NAME environment variable
Status: RESOLVED FIXED
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: 19.04.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-04-27 07:57 UTC by Nikolaos Kakouros
Modified: 2019-09-27 02:31 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolaos Kakouros 2019-04-27 07:57:55 UTC
SUMMARY
When switching profiles from the context menu or the menu bar, `echo $KONSOLE_PROFILE_NAME` does not get update and holds the name of the default profile.

STEPS TO REPRODUCE
1. Run konsole
2. Switch the profile from the context menu
3. `echo $KONSOLE_PROFILE_NAME`

OBSERVED RESULT
The variable contains the name of the previous profile.

EXPECTED RESULT
The variable should reflect the name of the new profile.
Comment 1 Kurt Hindenburg 2019-08-17 15:59:23 UTC
You are correct
Comment 2 Kurt Hindenburg 2019-08-17 22:08:45 UTC
I now remember a similar question was asked before.  In Linux, you can't change the environment variables of an already running process.  You're better off starting a new session.

I wonder if switching profiles needs to be removed all together or perhaps switching profiles is just really a new session in the same tab (using new process).
Comment 3 Mariusz Glebocki 2019-08-18 10:42:29 UTC
Good solution would be to provide dbus function and konsole command line argument for getting profile name.

(In reply to Kurt Hindenburg from comment #2)
> I wonder if switching profiles needs to be removed all together or perhaps
> switching profiles is just really a new session in the same tab (using new
> process).

The problem with profiles is that they represent both session/startup options (mostly first configuration page) and look/feel options.
* Startup options are applicable only for new sessions.
* Look/feel options are mostly shared between session. Users might want to change those for specific session without restarting it (e.g. swiching to light color scheme when going outside on sunny day). It is currently possible for e.g. scrollback size, tab title format, font size.

There are also window settings, which doesn't make sense when opening a new tab (initial window size, "size hint after window resize", etc) or in a kpart.

Another problem is lack of option sharing. When an user finds their new favourite font, or finds out some interaction-related option suits them better, in most cases they want to use them in all their profiles.
Comment 4 Kurt Hindenburg 2019-08-18 16:48:02 UTC
I agree w/ the dbus suggestions - I don't recall why we started using some of the environment variables.
Comment 5 Kurt Hindenburg 2019-09-27 02:15:24 UTC
Git commit 05f5663a90106ee8ddcff024c9b30b2b8f1e0f4f by Kurt Hindenburg.
Committed on 27/09/2019 at 02:12.
Pushed by hindenburg into branch 'master'.

Add dbus profile() to return profile name of current session

Instead of relying on env variable KONSOLE_PROFILE_NAME, which is
invalid upon switching profiles, use a dbus method profile().

qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_SESSION profile

M  +4    -0    src/Session.cpp
M  +5    -0    src/Session.h

https://invent.kde.org/kde/konsole/commit/05f5663a90106ee8ddcff024c9b30b2b8f1e0f4f
Comment 6 Kurt Hindenburg 2019-09-27 02:15:27 UTC
Git commit 05f5663a90106ee8ddcff024c9b30b2b8f1e0f4f by Kurt Hindenburg.
Committed on 27/09/2019 at 02:12.
Pushed by scmsync into branch 'master'.

Add dbus profile() to return profile name of current session

Instead of relying on env variable KONSOLE_PROFILE_NAME, which is
invalid upon switching profiles, use a dbus method profile().

qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_SESSION profile

M  +4    -0    src/Session.cpp
M  +5    -0    src/Session.h

https://commits.kde.org/konsole/05f5663a90106ee8ddcff024c9b30b2b8f1e0f4f
Comment 7 Kurt Hindenburg 2019-09-27 02:31:13 UTC
Git commit 9e3a30fdca2078e04bee2315ebd2adf678a81263 by Kurt Hindenburg.
Committed on 27/09/2019 at 02:24.
Pushed by hindenburg into branch 'master'.

Remove env variable KONSOLE_PROFILE_NAME

env variables can not be changed after process creation so this
causes this variable to be wrong after profile switching.  Use the
dbus method profile to determine name.
qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_SESSION profile

M  +0    -1    src/SessionManager.cpp

https://invent.kde.org/kde/konsole/commit/9e3a30fdca2078e04bee2315ebd2adf678a81263
Comment 8 Kurt Hindenburg 2019-09-27 02:31:17 UTC
Git commit 9e3a30fdca2078e04bee2315ebd2adf678a81263 by Kurt Hindenburg.
Committed on 27/09/2019 at 02:24.
Pushed by scmsync into branch 'master'.

Remove env variable KONSOLE_PROFILE_NAME

env variables can not be changed after process creation so this
causes this variable to be wrong after profile switching.  Use the
dbus method profile to determine name.
qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_SESSION profile

M  +0    -1    src/SessionManager.cpp

https://commits.kde.org/konsole/9e3a30fdca2078e04bee2315ebd2adf678a81263