Browse Source

Pass environment variables from shell to systemd

Instead of having the systemd user units in .config/systemd/user/ who's
programs require access to a environment variable to define them
explicitly using "Environment = 'VAR=value'". Instead from .bashrc and
.zshrc we can import all environment variables using "systemctl --user
import-environment" or import variables individually like so "systemctl
--user import-environment VAR_NAME".

Here I import (using the method above) both $PATH and $SMLNJ_HOME so
that they can be used by emacs (and maybe some other
program/systemd-user-unit I have forgotten).

Signed-off-by: Collin J. Doering <rekahsoft@gmail.com>
master
Collin J. Doering 7 years ago
committed by Collin J. Doering
parent
commit
cff91a9110
6 changed files with 12 additions and 6 deletions
  1. +6
    -1
      .bashrc
  2. +0
    -1
      .config/systemd/user/emacs.service
  3. +0
    -1
      .config/systemd/user/unclutter.service
  4. +0
    -1
      .config/systemd/user/xbindkeys.service
  5. +0
    -1
      .config/systemd/user/xscreensaver.service
  6. +6
    -1
      .zshrc

+ 6
- 1
.bashrc View File

@ -48,7 +48,12 @@ stty stop undef
# * mathematica / tools
# * nxclient / associated tools
# * maven tools
export PATH=export PATH=$HOME/.cabal/bin:$HOME/.gem/ruby/2.0.0/bin:$HOME/.bin:$HOME/.texlive/2013/bin/x86_64-linux:${PATH}:/opt/maven/bin:/opt/NX/bin
export PATH=export PATH=$HOME/.cabal/bin:$HOME/.gem/ruby/2.0.0/bin:$HOME/.bin:$HOME/.texlive/2014/bin/x86_64-linux:${PATH}:/opt/maven/bin:/opt/NX/bin:/usr/lib/smlnj/bin
ctlu import-environment PATH
# Setup smlnj (AUR)
export SMLNJ_HOME="/usr/lib/smlnj"
ctlu import-environment SMLNJ_HOME
# Setup gpg-agent
if [ -f "${HOME}/.gpg-agent-info" ]; then


+ 0
- 1
.config/systemd/user/emacs.service View File

@ -5,7 +5,6 @@ Description = Emacs: the extensible, self-documenting text editor
Type = forking
ExecStart = /usr/bin/emacs --daemon
ExecStop = /usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
Environment = "PATH=/home/collin/.cabal/bin:/home/collin/.gem/ruby/2.0.0/bin:/home/collin/.bin:/home/collin/.texlive/2013/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/android-sdk/platform-tools:/opt/android-sdk/tools:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/smlnj/bin:/opt/maven/bin:/opt/NX/bin"
Restart = always
[Install]


+ 0
- 1
.config/systemd/user/unclutter.service View File

@ -4,7 +4,6 @@ Description = Remove idle cursor image from screen
[Service]
type = simple
ExecStart = /usr/bin/unclutter
Environment = "DISPLAY=:0"
Restart = always
[Install]


+ 0
- 1
.config/systemd/user/xbindkeys.service View File

@ -3,7 +3,6 @@ Description = A grabbing keys program for X
[Service]
ExecStart = /usr/bin/xbindkeys -n -f %h/.xbindkeysrc
Environment = "DISPLAY=:0"
Restart = always
[Install]


+ 0
- 1
.config/systemd/user/xscreensaver.service View File

@ -3,7 +3,6 @@ Description = Extensible screen saver framework, plus locking
[Service]
ExecStart = /usr/bin/xscreensaver -no-splash
Environment = "DISPLAY=:0"
Restart = always
[Install]


+ 6
- 1
.zshrc View File

@ -81,7 +81,12 @@ stty stop undef
# * mathematica / tools
# * nxclient / associated tools
# * maven tools
export PATH=$HOME/.cabal/bin:$HOME/.gem/ruby/2.0.0/bin:$HOME/.bin:$HOME/.texlive/2013/bin/x86_64-linux:${PATH}:/opt/maven/bin:/opt/NX/bin
export PATH=$HOME/.cabal/bin:$HOME/.gem/ruby/2.0.0/bin:$HOME/.bin:$HOME/.texlive/2014/bin/x86_64-linux:${PATH}:/opt/maven/bin:/opt/NX/bin:/usr/lib/smlnj/bin
ctlu import-environment PATH
# Setup smlnj (AUR)
export SMLNJ_HOME="/usr/lib/smlnj"
ctlu import-environment SMLNJ_HOME
# Setup gpg-agent
if [ -f "${HOME}/.gpg-agent-info" ]; then


Loading…
Cancel
Save