fix(package): detect current user when installing DEB through a GUI#757
fix(package): detect current user when installing DEB through a GUI#757
Conversation
resources-linux/postinst
Outdated
| fi | ||
|
|
||
| # Method 2: Check loginctl for latest session | ||
| username=$(loginctl list-users --no-legend | awk '$1 >= 1000 {print $2; exit}') |
There was a problem hiding this comment.
I don't think this is correct on a multi-user environment
| SESSION_ID=$(loginctl show-seat seat0 -p ActiveSession --value) | ||
| username=$(loginctl show-session "$SESSION_ID" -p Name --value) |
There was a problem hiding this comment.
I'm not sure if it's correct to rely on seat0 being the one running the installation, but I don't know much about multi-seat environments so I could be wrong. Maybe it's better to do something like loginctl show-session $(cat /proc/self/sessionid) -p Name --value?
There was a problem hiding this comment.
I'm also not very familiar with multi-seat setups, but my understanding is that in typical workstation situation it's always the default seat0 since each seat corresponds to a set of hardware (keyboard, mouse etc).
There would be more than one in for example some thin-client setup, which we don't explicitly support.
I did run some tests on Ubuntu 22/24, Debian 12/13 and Fedora and this approach seems to work.
Add a fallback method for checking current user in the DEB & RPM package postinst script. This should enable the package to determine current user when being installed from a GUI frontend (Ubuntu App Center etc).
Closes #755