You are not logged in.

#1 2020-06-19 14:26:56

mjd119
Member
Registered: 2020-05-07
Posts: 119

[SOLVED] Environment variables not exported with i3 startx

I am trying to use startx to start i3 instead of using the SDDM display manager like I was doing for a while (I'm trying to limit system resource usage). When I export environment variables, the variables are honored based on how my qt and gtk apps look. When I log in with text mode and then execute startx, the environment variable exports aren't honored and my imwheel.service failed.
my ~/.xinitrc is:

# Added by mjd119 (Arch Wiki)
[[ -f ~/.Xresources ]] && xrdb -merge -I$HOME ~/.Xresources
# Start i3 if we call startx instead of using display manager
# Consistent file dialog (Arch Wiki)
# Make sure this is before the 'exec' command or it won't be sourced. (from Arch Wiki)
[ -f /etc/xprofile ] && . /etc/xprofile
[ -f ~/.xprofile ] && . ~/.xprofile
exec i3

my ~/.xprofile is:

#!/bin/sh
# Added by mjd119 to configure qt,gtk, etc. for i3 (SDDM sources .xprofile, not .xinitrc)
if [ $XDG_SESSION_DESKTOP != KDE ]
	then export QT_QPA_PLATFORMTHEME=qt5ct
fi
# Consistent file dialog (Arch Wiki)
export GTK_USE_PORTAL=1
# Proper scaling for QT apps (Arch Wiki)
export QT_SCREEN_SCALE_FACTORS=1.75
export QT_AUTO_SCREEN_SCALE_FACTOR=0

my ~/.config/systemd/user/imwheel.service is:

# Service file from Arch Wiki (mjd119 added -b 45 argument to enable front/back buttons)
# Restart on failure line added from https://bbs.archlinux.org/viewtopic.php?id=250540
[Unit]
Description=IMWheel
Wants=display-manager.service
After=display-manager.service

[Service]
Type=simple
Environment=XAUTHORITY=%h/.Xauthority
ExecStart=/usr/bin/imwheel -d -b 45 
ExecStop=/usr/bin/pkill imwheel
RemainAfterExit=yes
Restart=on-failure
[Install]
WantedBy=default.target

and the partial output of "journalctl -xe | grep imwheel" is:

Jun 19 09:59:50 Arch imwheel[857]: INFO: imwheel is not running as a daemon.
Jun 19 09:59:50 Arch imwheel[857]: INFO: imwheel started (pid=857)
Jun 19 09:59:50 Arch imwheel[857]: Could not open display, check shell DISPLAY variable, and export or setenv it!
Jun 19 09:59:50 Arch systemd[802]: imwheel.service: Main process exited, code=exited, status=1/FAILURE
Jun 19 09:59:50 Arch systemd[802]: imwheel.service: Failed with result 'exit-code'.
Jun 19 09:59:51 Arch systemd[802]: imwheel.service: Scheduled restart job, restart counter is at 3.

which keeps repeating.
I can provide my /etc/xprofile file. I haven't modified it since I installed Arch though. My default shell is zsh, but I would prefer to export environment variables independent of my shell so I can switch to bash, fish, or others without making multiple files for each shell.
EDIT:
I also noticed the output of "journalctl -xe | grep "[Ff]ailed"" is:

Jun 19 09:59:39 Arch nordvpnd[680]: 2020/06/19 09:59:39 [Error] ntp check failed
Jun 19 09:59:50 Arch audit[802]: CRED_ACQ pid=802 uid=0 auid=4294967295 ses=4294967295 msg='op=PAM:setcred grantors=? acct="matt" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
Jun 19 09:59:50 Arch kernel: audit: type=1103 audit(1592575190.479:34): pid=802 uid=0 auid=4294967295 ses=4294967295 msg='op=PAM:setcred grantors=? acct="matt" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed'
Jun 19 09:59:50 Arch systemd[802]: imwheel.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'exit-code'.
Jun 19 09:59:50 Arch python3[810]: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
Jun 19 09:59:50 Arch python3[810]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:50 Arch python3[810]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:50 Arch python3[810]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:50 Arch systemd[802]: imwheel.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'exit-code'.
Jun 19 09:59:50 Arch systemd[802]: redshift-gtk.service: Failed with result 'core-dump'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'core-dump'.
Jun 19 09:59:50 Arch systemd[802]: imwheel.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'exit-code'.
Jun 19 09:59:51 Arch systemd[802]: imwheel.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'exit-code'.
Jun 19 09:59:51 Arch python3[866]: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
Jun 19 09:59:51 Arch python3[866]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:51 Arch python3[866]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:51 Arch python3[866]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:51 Arch systemd[802]: imwheel.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'exit-code'.
Jun 19 09:59:51 Arch systemd[802]: redshift-gtk.service: Failed with result 'core-dump'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'core-dump'.
Jun 19 09:59:51 Arch systemd[802]: imwheel.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'exit-code'.
Jun 19 09:59:51 Arch systemd[802]: Failed to start IMWheel.
-- Subject: A start job for unit UNIT has failed
-- The job identifier is 105 and the job result is failed.
Jun 19 09:59:51 Arch python3[878]: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
Jun 19 09:59:51 Arch python3[878]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:51 Arch python3[878]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:51 Arch python3[878]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:52 Arch systemd[802]: redshift-gtk.service: Failed with result 'core-dump'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'core-dump'.
Jun 19 09:59:52 Arch python3[892]: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
Jun 19 09:59:52 Arch python3[892]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:52 Arch python3[892]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:52 Arch python3[892]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:52 Arch systemd[802]: redshift-gtk.service: Failed with result 'core-dump'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'core-dump'.
Jun 19 09:59:52 Arch python3[904]: gtk_widget_get_scale_factor: assertion 'GTK_IS_WIDGET (widget)' failed
Jun 19 09:59:52 Arch python3[904]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:52 Arch python3[904]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:52 Arch python3[904]: _gtk_style_provider_private_get_settings: assertion 'GTK_IS_STYLE_PROVIDER_PRIVATE (provider)' failed
Jun 19 09:59:52 Arch systemd[802]: redshift-gtk.service: Failed with result 'core-dump'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'core-dump'.
Jun 19 09:59:53 Arch systemd[802]: redshift-gtk.service: Failed with result 'core-dump'.
-- Subject: Unit failed
-- The unit UNIT has entered the 'failed' state with result 'core-dump'.
Jun 19 09:59:53 Arch systemd[802]: Failed to start Redshift display colour temperature adjustment (GUI).
-- Subject: A start job for unit UNIT has failed
-- The job identifier is 169 and the job result is failed.
Jun 19 09:59:53 Arch kernel: platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
Jun 19 09:59:53 Arch kernel: cfg80211: failed to load regulatory.db
Jun 19 10:00:02 Arch CROND[1436]: (root) CMDOUT ((process:1437): GLib-GIO-CRITICAL **: 10:00:02.015: g_file_get_path: assertion 'G_IS_FILE (file)' failed)
Jun 19 10:00:02 Arch CROND[1436]: (root) CMDOUT (** (process:1437): CRITICAL **: 10:00:02.015: tee_jee_file_system_path_combine: assertion 'path1 != NULL' failed)
Jun 19 10:00:02 Arch CROND[1436]: (root) CMDOUT (** (process:1437): CRITICAL **: 10:00:02.015: tee_jee_file_system_dir_exists: assertion 'dir_path != NULL' failed)
Jun 19 10:00:04 Arch kactivitymanagerd[1537]: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Jun 19 10:00:04 Arch dbus-daemon[1140]: [session uid=1000 pid=1140] Activated service 'org.kde.ActivityManager' failed: Process org.kde.ActivityManager received signal 6
Jun 19 10:00:04 Arch kactivitymanagerd[1545]: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Jun 19 10:00:05 Arch dbus-daemon[1140]: [session uid=1000 pid=1140] Activated service 'org.kde.ActivityManager' failed: Process org.kde.ActivityManager received signal 6
Jun 19 10:00:08 Arch kactivitymanagerd[1607]: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Jun 19 10:00:08 Arch dbus-daemon[1140]: [session uid=1000 pid=1140] Activated service 'org.kde.ActivityManager' failed: Process org.kde.ActivityManager received signal 6
Jun 19 10:00:48 Arch dbus-daemon[668]: [system] Activation via systemd failed for unit 'dbus-org.bluez.service': Unit dbus-org.bluez.service not found.
Jun 19 10:00:54 Arch dbus-daemon[1140]: [session uid=1000 pid=1140] Activated service 'org.freedesktop.Notifications' failed: Process org.freedesktop.Notifications exited with status 1
Jun 19 10:01:54 Arch dbus-daemon[1140]: [session uid=1000 pid=1140] Activated service 'org.freedesktop.Notifications' failed: Process org.freedesktop.Notifications exited with status 1
Jun 19 10:09:43 Arch dbus-daemon[668]: [system] Activation via systemd failed for unit 'dbus-org.bluez.service': Unit dbus-org.bluez.service not found.
Jun 19 10:25:33 Arch dbus-daemon[668]: [system] Activation via systemd failed for unit 'dbus-org.bluez.service': Unit dbus-org.bluez.service not found.

Last edited by mjd119 (2020-06-19 17:39:21)

Offline

#2 2020-06-19 14:42:25

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,518
Website

Re: [SOLVED] Environment variables not exported with i3 startx

Do you think these have anything to do with each other?  I don't.  You have two completely different issues.  Which one do you want to focus on in this thread: environment variables not being respected, or the imwheel service failing?  Pick one, then provide more information about it.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2020-06-19 14:46:05

mjd119
Member
Registered: 2020-05-07
Posts: 119

Re: [SOLVED] Environment variables not exported with i3 startx

Trilby wrote:

Do you think these have anything to do with each other?  I don't.  You have two completely different issues.  Which one do you want to focus on in this thread: environment variables not being respected, or the imwheel service failing?  Pick one, then provide more information about it.

I would say setting the environment variables for now. I think I need to set a certain environment variable to get the imwheel service to work properly anyway.

Offline

#4 2020-06-19 14:49:49

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,518
Website

Re: [SOLVED] Environment variables not exported with i3 startx

No, the two have nothing to do with each other (other than that they both come from improperly transitioning from a DM to startx).

But if you want to investigate the environment variables you need to tell us about that problem.  How do you infer that they are not being honored?  Are they present in the environment of a terminal emulator under i3?  How do you launch the programs that are allegedly not respecting those variables?

Last edited by Trilby (2020-06-19 14:50:41)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2020-06-19 14:55:41

mjd119
Member
Registered: 2020-05-07
Posts: 119

Re: [SOLVED] Environment variables not exported with i3 startx

Trilby wrote:

No, the two have nothing to do with each other (other than that they both come from improperly transitioning from a DM to startx).

But if you want to investigate the environment variables you need to tell us about that problem.  How do you infer that they are not being honored?  Are they present in the environment of a terminal emulator under i3?  How do you launch the programs that are allegedly not respecting those variables?

When I was using a Display Manager, the QT_QPA_PLATFORM_THEME value is set to qt5ct, but it isn't when I use startx (I get a warning within qt5ct when I start i3 with startx). I now have qt apps that fallback to the default theme. When I call printenv, none of the variables I am trying to export appear.

Last edited by mjd119 (2020-06-19 14:56:19)

Offline

#6 2020-06-19 16:19:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,518
Website

Re: [SOLVED] Environment variables not exported with i3 startx

How do you start qt5ct and the terminal you call printenv from?  Please post the complete output of printenv from a terminal in i3.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2020-06-19 16:23:12

mjd119
Member
Registered: 2020-05-07
Posts: 119

Re: [SOLVED] Environment variables not exported with i3 startx

Trilby wrote:

How do you start qt5ct and the terminal you call printenv from?  Please post the complete output of printenv from a terminal in i3.

I call from the Termite terminal using zsh as the shell (same result with bash). The output of printenv is:

GTK_USE_PORTAL=1
PAGER=most
LANG=en_US.UTF-8
HOME=/home/matt
USER=matt
OLDPWD=/home/matt
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
XDG_VTNR=1
XDG_SEAT=seat0
I3SOCK=/run/user/1000/i3/ipc-socket.1206
LESS=-R
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
_=/usr/bin/printenv
WINDOWPATH=1
JOURNAL_STREAM=9:31771
VTE_VERSION=5602
LSCOLORS=Gxfxcxdxbxegedabagacad
QT_SCREEN_SCALE_FACTORS=1.75
MAIL=/var/spool/mail/matt
LOGNAME=matt
QT_AUTO_SCREEN_SCALE_FACTOR=0
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
XDG_RUNTIME_DIR=/run/user/1000
WINDOWID=41943043
XDG_SESSION_ID=1
SHELL=/usr/bin/zsh
XDG_SESSION_TYPE=tty
INVOCATION_ID=9ab91b2f744a4a9d938696ff5221a022
SHLVL=3
XAUTHORITY=/home/matt/.Xauthority
PWD=/home/matt
XDG_SESSION_CLASS=user
TERM=xterm-termite
COLORTERM=truecolor
DISPLAY=:0

Offline

#8 2020-06-19 17:09:09

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Environment variables not exported with i3 startx

:

mjd119 wrote:

my ~/.xprofile is:

#!/bin/sh
# Added by mjd119 to configure qt,gtk, etc. for i3 (SDDM sources .xprofile, not .xinitrc)
if [ $XDG_SESSION_DESKTOP != KDE ]
	then export QT_QPA_PLATFORMTHEME=qt5ct
fi

Two issues here:

  1. that should be $XDG_DESKTOP_SESSION

  2. you forgot to quote the variable:

~$ bash
~$ if [ $XDG_SESSION_DESKTOP != KDE ]
> then echo not KDE
> fi
bash: [: !=: unary operator expected
~$

Correct version:

if [ "$XDG_DESKTOP_SESSION" != KDE ]
	then export QT_QPA_PLATFORMTHEME=qt5ct
fi

Or leave it unquoted and switch to a /bin/bash shebang and the bash [[ test instead: https://stackoverflow.com/questions/136 … -condition


Jin, Jîyan, Azadî

Offline

#9 2020-06-19 17:38:46

mjd119
Member
Registered: 2020-05-07
Posts: 119

Re: [SOLVED] Environment variables not exported with i3 startx

Head_on_a_Stick wrote:

:

mjd119 wrote:

my ~/.xprofile is:

#!/bin/sh
# Added by mjd119 to configure qt,gtk, etc. for i3 (SDDM sources .xprofile, not .xinitrc)
if [ $XDG_SESSION_DESKTOP != KDE ]
	then export QT_QPA_PLATFORMTHEME=qt5ct
fi

Two issues here:

  1. that should be $XDG_DESKTOP_SESSION

  2. you forgot to quote the variable:

~$ bash
~$ if [ $XDG_SESSION_DESKTOP != KDE ]
> then echo not KDE
> fi
bash: [: !=: unary operator expected
~$

Correct version:

if [ "$XDG_DESKTOP_SESSION" != KDE ]
	then export QT_QPA_PLATFORMTHEME=qt5ct
fi

Or leave it unquoted and switch to a /bin/bash shebang and the bash [[ test instead: https://stackoverflow.com/questions/136 … -condition

That solved the issue. Thank you. I've researched the difference between the /bash and /sh lines in scripts but I still don't understand it fully. I will mark this issue as solved.

Offline

Board footer

Powered by FluxBB