From 757bd4c26dcb2026ff16b348b71f1f1e91585e7e Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Sat, 21 Mar 2020 21:27:43 +0000 Subject: [PATCH] systemd: launch i3 and user programs with systemd --- .config/X11/xprofile | 7 ------ .config/i3/config | 25 ++----------------- .../systemd/user/autocutsel-primary.service | 10 ++++++++ .config/systemd/user/autocutsel.service | 10 ++++++++ .../user/basic.target.wants/profile.service | 1 + .config/systemd/user/blueman-applet.service | 12 +++++++++ .config/systemd/user/default.target | 1 + .../user/default.target.wants/dunst.service | 1 + .../default.target.wants/redshift.service | 1 + .../blueman-applet.service | 1 + .../user/desktop.target.wants/dunst.service | 1 + .../desktop.target.wants/nextcloud.service | 1 + .../user/desktop.target.wants/picom.service | 1 + .../polybar@i3bar.service | 1 + .../user/desktop.target.wants/solaar.service | 1 + .../xdg-user-dirs-update.service | 1 + .../autocutsel-primary.service | 1 + .../autocutsel.service | 1 + .../graphical-session.target.wants/i3.service | 1 + .config/systemd/user/i3.service | 14 +++++++++++ .config/systemd/user/nextcloud.service | 14 +++++++++++ .config/systemd/user/picom.service | 12 +++++++++ .config/systemd/user/polybar@.service | 12 +++++++++ .config/systemd/user/profile.service | 10 ++++++++ .../systemd/user/sleep-lock-lightdm.service | 1 + .../sleep-lock-lightdm.service | 2 +- .config/systemd/user/solaar.service | 13 ++++++++++ .config/systemd/user/xautolock.service | 10 ++++++++ .config/systemd/user/xbindkeys.service | 11 ++++++++ .config/systemd/user/xorg.target | 3 +++ .../user/xorg.target.wants/xprofile.service | 1 + .config/systemd/user/xprofile.service | 13 ++++++++++ .profile | 14 ++++------- aliases | 8 +++--- 34 files changed, 173 insertions(+), 43 deletions(-) create mode 100644 .config/systemd/user/autocutsel-primary.service create mode 100644 .config/systemd/user/autocutsel.service create mode 120000 .config/systemd/user/basic.target.wants/profile.service create mode 100644 .config/systemd/user/blueman-applet.service create mode 120000 .config/systemd/user/default.target create mode 120000 .config/systemd/user/default.target.wants/dunst.service create mode 120000 .config/systemd/user/default.target.wants/redshift.service create mode 120000 .config/systemd/user/desktop.target.wants/blueman-applet.service create mode 120000 .config/systemd/user/desktop.target.wants/dunst.service create mode 120000 .config/systemd/user/desktop.target.wants/nextcloud.service create mode 120000 .config/systemd/user/desktop.target.wants/picom.service create mode 120000 .config/systemd/user/desktop.target.wants/polybar@i3bar.service create mode 120000 .config/systemd/user/desktop.target.wants/solaar.service create mode 120000 .config/systemd/user/desktop.target.wants/xdg-user-dirs-update.service create mode 120000 .config/systemd/user/graphical-session.target.wants/autocutsel-primary.service create mode 120000 .config/systemd/user/graphical-session.target.wants/autocutsel.service create mode 120000 .config/systemd/user/graphical-session.target.wants/i3.service create mode 100644 .config/systemd/user/i3.service create mode 100644 .config/systemd/user/nextcloud.service create mode 100644 .config/systemd/user/picom.service create mode 100644 .config/systemd/user/polybar@.service create mode 100644 .config/systemd/user/profile.service create mode 100644 .config/systemd/user/solaar.service create mode 100644 .config/systemd/user/xautolock.service create mode 100644 .config/systemd/user/xbindkeys.service create mode 100644 .config/systemd/user/xorg.target create mode 120000 .config/systemd/user/xorg.target.wants/xprofile.service create mode 100644 .config/systemd/user/xprofile.service diff --git a/.config/X11/xprofile b/.config/X11/xprofile index 8046c45..2569d3e 100644 --- a/.config/X11/xprofile +++ b/.config/X11/xprofile @@ -15,10 +15,3 @@ xrandr --dpi $(xrdb -query | grep -i xft.dpi | cut -d: -f2) setxkbmap -option caps:none xset r rate 200 18 - - -# Merge system clipboards -if [ -n "$DISPLAY" ] && exists autocutsel && ! pidof autocutsel 1>/dev/null; then - autocutsel -fork - autocutsel -selection PRIMARY -fork -fi diff --git a/.config/i3/config b/.config/i3/config index c5feed6..77e511f 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -107,7 +107,6 @@ client.unfocused $inactive-bg-color $inactive-bg-color $inactive-text-co client.focused_inactive $inactive-bg-color $inactive-bg-color $inactive-text-color $bg-color client.urgent $urgent-bg-color $urgent-bg-color $text-color $bg-color -exec_always --no-startup-id killall -q polybar; while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done; exec polybar -r i3bar exec_always --no-startup-id feh --no-fehbg --no-xinerama --bg-fill $DOTFILES/lakesidesunrise.jpg # Window rules @@ -130,7 +129,8 @@ focus_follows_mouse yes # keybindings bindsym $mod+Shift+j reload -bindsym $mod+c exec chromium +bindsym $mod+c exec systemd-run --user --scope --slice=chromium.slice --no-block -- chromium +bindsym $mod+b exec systemd-run --user --scope --slice=firefox.slice --no-block -- firefox bindsym $mod+v exec "i3-sensible-terminal -e \\"$SHELL -c vim;$SHELL\\" bindsym $mod+Ctrl+v exec "i3-sensible-terminal -r floating-term -e \\"$SHELL -c vim;$SHELL\\" bindsym $mod+Return exec i3-sensible-terminal @@ -162,25 +162,4 @@ bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFA bindsym XF86MonBrightnessUp exec xbacklight -inc 5 && pkill -RTMIN+12 i3blocks bindsym XF86MonBrightnessDown exec xbacklight -dec 5 && pkill -RTMIN+12 i3blocks -# app launch shortcuts -exec --no-startup-id ~/.config/i3/disable-standby-fs.py -exec --no-startup-id feh --no-fehbg --no-xinerama --bg-fill ~/pictures/lakesidesunrise.jpg -exec --no-startup-id xautolock -time 5 -locker 'dm-tool switch-to-greeter' -nocloseout -nocloseerr -exec --no-startup-id xss-lock dm-tool switch-to-greeter - -# startup programs -exec --no-startup-id nextcloud -exec --no-startup-id blueman-applet -exec --no-startup-id redshift -exec --no-startup-id xbindkeys -exec --no-startup-id solaar -exec --no-startup-id pullover -exec --no-startup-id mailnag -exec --no-startup-id picom -b --experimental-backends -exec --no-startup-id chromium --no-startup-window -exec --no-startup-id thunderbird - -exec i3-msg 'workspace 1; exec sleep 2 && chromium' -exec i3-msg 'workspace 2; exec i3-sensible-terminal' - # vim:ft=i3 diff --git a/.config/systemd/user/autocutsel-primary.service b/.config/systemd/user/autocutsel-primary.service new file mode 100644 index 0000000..99d5dde --- /dev/null +++ b/.config/systemd/user/autocutsel-primary.service @@ -0,0 +1,10 @@ +[Unit] +Description=autocutsel -selection primary +PartOf=graphical-session.target + +[Service] +ExecStart=/usr/bin/autocutsel -selection PRIMARY + +[Install] +WantedBy=graphical-session.target + diff --git a/.config/systemd/user/autocutsel.service b/.config/systemd/user/autocutsel.service new file mode 100644 index 0000000..da2b70b --- /dev/null +++ b/.config/systemd/user/autocutsel.service @@ -0,0 +1,10 @@ +[Unit] +Description=autocutsel +PartOf=graphical-session.target + +[Service] +ExecStart=/usr/bin/autocutsel + +[Install] +WantedBy=graphical-session.target + diff --git a/.config/systemd/user/basic.target.wants/profile.service b/.config/systemd/user/basic.target.wants/profile.service new file mode 120000 index 0000000..a975817 --- /dev/null +++ b/.config/systemd/user/basic.target.wants/profile.service @@ -0,0 +1 @@ +/home/frebib/.config/systemd/user/profile.service \ No newline at end of file diff --git a/.config/systemd/user/blueman-applet.service b/.config/systemd/user/blueman-applet.service new file mode 100644 index 0000000..fb63902 --- /dev/null +++ b/.config/systemd/user/blueman-applet.service @@ -0,0 +1,12 @@ +[Unit] +Description=Bluetooth Applet +After=graphical-session.target bluetooth.service +Requires=graphical-session.target bluetooth.service + +[Service] +Type=simple +ExecStart=/usr/bin/blueman-applet +Restart=on-failure + +[Install] +WantedBy=desktop.target diff --git a/.config/systemd/user/default.target b/.config/systemd/user/default.target new file mode 120000 index 0000000..bead1e2 --- /dev/null +++ b/.config/systemd/user/default.target @@ -0,0 +1 @@ +/usr/lib/systemd/user/basic.target \ No newline at end of file diff --git a/.config/systemd/user/default.target.wants/dunst.service b/.config/systemd/user/default.target.wants/dunst.service new file mode 120000 index 0000000..b24d3b1 --- /dev/null +++ b/.config/systemd/user/default.target.wants/dunst.service @@ -0,0 +1 @@ +/usr/lib/systemd/user/dunst.service \ No newline at end of file diff --git a/.config/systemd/user/default.target.wants/redshift.service b/.config/systemd/user/default.target.wants/redshift.service new file mode 120000 index 0000000..a9cf4c7 --- /dev/null +++ b/.config/systemd/user/default.target.wants/redshift.service @@ -0,0 +1 @@ +/usr/lib/systemd/user/redshift.service \ No newline at end of file diff --git a/.config/systemd/user/desktop.target.wants/blueman-applet.service b/.config/systemd/user/desktop.target.wants/blueman-applet.service new file mode 120000 index 0000000..474ae13 --- /dev/null +++ b/.config/systemd/user/desktop.target.wants/blueman-applet.service @@ -0,0 +1 @@ +/home/frebib/.config/systemd/user/blueman-applet.service \ No newline at end of file diff --git a/.config/systemd/user/desktop.target.wants/dunst.service b/.config/systemd/user/desktop.target.wants/dunst.service new file mode 120000 index 0000000..b24d3b1 --- /dev/null +++ b/.config/systemd/user/desktop.target.wants/dunst.service @@ -0,0 +1 @@ +/usr/lib/systemd/user/dunst.service \ No newline at end of file diff --git a/.config/systemd/user/desktop.target.wants/nextcloud.service b/.config/systemd/user/desktop.target.wants/nextcloud.service new file mode 120000 index 0000000..f893d3b --- /dev/null +++ b/.config/systemd/user/desktop.target.wants/nextcloud.service @@ -0,0 +1 @@ +/home/frebib/.config/systemd/user/nextcloud.service \ No newline at end of file diff --git a/.config/systemd/user/desktop.target.wants/picom.service b/.config/systemd/user/desktop.target.wants/picom.service new file mode 120000 index 0000000..6dd30f3 --- /dev/null +++ b/.config/systemd/user/desktop.target.wants/picom.service @@ -0,0 +1 @@ +/home/frebib/.config/systemd/user/picom.service \ No newline at end of file diff --git a/.config/systemd/user/desktop.target.wants/polybar@i3bar.service b/.config/systemd/user/desktop.target.wants/polybar@i3bar.service new file mode 120000 index 0000000..8713be3 --- /dev/null +++ b/.config/systemd/user/desktop.target.wants/polybar@i3bar.service @@ -0,0 +1 @@ +/home/frebib/.config/systemd/user/polybar@.service \ No newline at end of file diff --git a/.config/systemd/user/desktop.target.wants/solaar.service b/.config/systemd/user/desktop.target.wants/solaar.service new file mode 120000 index 0000000..bad4291 --- /dev/null +++ b/.config/systemd/user/desktop.target.wants/solaar.service @@ -0,0 +1 @@ +/home/frebib/.config/systemd/user/solaar.service \ No newline at end of file diff --git a/.config/systemd/user/desktop.target.wants/xdg-user-dirs-update.service b/.config/systemd/user/desktop.target.wants/xdg-user-dirs-update.service new file mode 120000 index 0000000..ee619a0 --- /dev/null +++ b/.config/systemd/user/desktop.target.wants/xdg-user-dirs-update.service @@ -0,0 +1 @@ +/usr/lib/systemd/user/xdg-user-dirs-update.service \ No newline at end of file diff --git a/.config/systemd/user/graphical-session.target.wants/autocutsel-primary.service b/.config/systemd/user/graphical-session.target.wants/autocutsel-primary.service new file mode 120000 index 0000000..f7a06fa --- /dev/null +++ b/.config/systemd/user/graphical-session.target.wants/autocutsel-primary.service @@ -0,0 +1 @@ +/home/frebib/.config/systemd/user/autocutsel-primary.service \ No newline at end of file diff --git a/.config/systemd/user/graphical-session.target.wants/autocutsel.service b/.config/systemd/user/graphical-session.target.wants/autocutsel.service new file mode 120000 index 0000000..b40a8f8 --- /dev/null +++ b/.config/systemd/user/graphical-session.target.wants/autocutsel.service @@ -0,0 +1 @@ +/home/frebib/.config/systemd/user/autocutsel.service \ No newline at end of file diff --git a/.config/systemd/user/graphical-session.target.wants/i3.service b/.config/systemd/user/graphical-session.target.wants/i3.service new file mode 120000 index 0000000..177acf2 --- /dev/null +++ b/.config/systemd/user/graphical-session.target.wants/i3.service @@ -0,0 +1 @@ +/home/frebib/.config/systemd/user/i3.service \ No newline at end of file diff --git a/.config/systemd/user/i3.service b/.config/systemd/user/i3.service new file mode 100644 index 0000000..011eb5b --- /dev/null +++ b/.config/systemd/user/i3.service @@ -0,0 +1,14 @@ +[Unit] +Description=i3 - an improved dynamic, tiling window manager +Requires=xorg.target +Before=graphical-session.target +After=profile.service xprofile.service xorg.target + +[Service] +ExecStart=/usr/bin/i3 +ExecReload=/bin/sh -c 'i3-msg restart; systemctl is-active --user -q picom && systemctl --user restart picom' +ExecStop=/bin/systemctl --user stop desktop.target +Restart=always + +[Install] +WantedBy=graphical-session.target diff --git a/.config/systemd/user/nextcloud.service b/.config/systemd/user/nextcloud.service new file mode 100644 index 0000000..38c0f96 --- /dev/null +++ b/.config/systemd/user/nextcloud.service @@ -0,0 +1,14 @@ +[Unit] +Description=Nextcloud Client +Requires=graphical-session.target +After=graphical-session.target + +[Service] +Type=simple +ExecStart=/usr/bin/nextcloud --background +ExecReload=/bin/kill -HUP $MAINPID +KillMode=process +Restart=on-failure + +[Install] +WantedBy=desktop.target diff --git a/.config/systemd/user/picom.service b/.config/systemd/user/picom.service new file mode 100644 index 0000000..ed9808f --- /dev/null +++ b/.config/systemd/user/picom.service @@ -0,0 +1,12 @@ +[Unit] +Description=A lightweight compositor for X11 +Requires=graphical-session.target +After=graphical-session.target xorg.target + +[Service] +Type=simple +ExecStart=/usr/bin/picom --experimental-backends --dbus +Restart=always + +[Install] +WantedBy=desktop.target diff --git a/.config/systemd/user/polybar@.service b/.config/systemd/user/polybar@.service new file mode 100644 index 0000000..89a3475 --- /dev/null +++ b/.config/systemd/user/polybar@.service @@ -0,0 +1,12 @@ +[Unit] +Description=Polybar +Requires=graphical-session.target +After=graphical-session.target pulseaudio.socket + +[Service] +Type=simple +ExecStart=/usr/bin/polybar --reload --log=warning %i +Restart=always + +[Install] +WantedBy=desktop.target diff --git a/.config/systemd/user/profile.service b/.config/systemd/user/profile.service new file mode 100644 index 0000000..3e524ce --- /dev/null +++ b/.config/systemd/user/profile.service @@ -0,0 +1,10 @@ +[Unit] +Description=Load profile environment into session +Before=graphical-session-pre.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/bash -c '. $HOME/.config/dotfiles/.profile && systemctl --user import-environment' + +[Install] +WantedBy=basic.target diff --git a/.config/systemd/user/sleep-lock-lightdm.service b/.config/systemd/user/sleep-lock-lightdm.service index 4221972..6f0016e 100644 --- a/.config/systemd/user/sleep-lock-lightdm.service +++ b/.config/systemd/user/sleep-lock-lightdm.service @@ -1,5 +1,6 @@ [Unit] Description=Lock X LightDM session before sleeping +Requires=graphical-session.target Before=sleep.target [Service] diff --git a/.config/systemd/user/sleep.target.wants/sleep-lock-lightdm.service b/.config/systemd/user/sleep.target.wants/sleep-lock-lightdm.service index 3da9b2a..65a414b 120000 --- a/.config/systemd/user/sleep.target.wants/sleep-lock-lightdm.service +++ b/.config/systemd/user/sleep.target.wants/sleep-lock-lightdm.service @@ -1 +1 @@ -../sleep-lock-lightdm.service \ No newline at end of file +/home/frebib/.config/systemd/user/sleep-lock-lightdm.service \ No newline at end of file diff --git a/.config/systemd/user/solaar.service b/.config/systemd/user/solaar.service new file mode 100644 index 0000000..40062d3 --- /dev/null +++ b/.config/systemd/user/solaar.service @@ -0,0 +1,13 @@ +[Unit] +Description=Solaar Logitech status applet +Requires=graphical-session.target +After=graphical-session.target + +[Service] +Type=simple +ExecStart=/usr/bin/solaar --restart-on-wake-up -d +KillMode=process +Restart=on-failure + +[Install] +WantedBy=desktop.target diff --git a/.config/systemd/user/xautolock.service b/.config/systemd/user/xautolock.service new file mode 100644 index 0000000..678d571 --- /dev/null +++ b/.config/systemd/user/xautolock.service @@ -0,0 +1,10 @@ +[Unit] +Description=XBindKeys + +[Service] +ExecStart=/usr/bin/xautolock -time 1 -locker 'dm-tool switch-to-greeter' -detectsleep -resetsaver -secure +KillMode=process +Restart=on-failure + +[Install] +WantedBy=graphical-session.target diff --git a/.config/systemd/user/xbindkeys.service b/.config/systemd/user/xbindkeys.service new file mode 100644 index 0000000..ef3b4c7 --- /dev/null +++ b/.config/systemd/user/xbindkeys.service @@ -0,0 +1,11 @@ +[Unit] +Description=XBindKeys +Requires=profile.service +After=profile.service + +[Service] +ExecStart=/usr/bin/xbindkeys -n -f $XDG_CONFIG_HOME/X11/xbindkeysrc +KillMode=process + +[Install] +WantedBy=graphical-session.target diff --git a/.config/systemd/user/xorg.target b/.config/systemd/user/xorg.target new file mode 100644 index 0000000..4fb253f --- /dev/null +++ b/.config/systemd/user/xorg.target @@ -0,0 +1,3 @@ +[Unit] +Description=Graphical desktop environment +Requires=basic.target diff --git a/.config/systemd/user/xorg.target.wants/xprofile.service b/.config/systemd/user/xorg.target.wants/xprofile.service new file mode 120000 index 0000000..3965f17 --- /dev/null +++ b/.config/systemd/user/xorg.target.wants/xprofile.service @@ -0,0 +1 @@ +/home/frebib/.config/systemd/user/xprofile.service \ No newline at end of file diff --git a/.config/systemd/user/xprofile.service b/.config/systemd/user/xprofile.service new file mode 100644 index 0000000..e3ab653 --- /dev/null +++ b/.config/systemd/user/xprofile.service @@ -0,0 +1,13 @@ +[Unit] +Description=Load Xorg configuration +PartOf=xorg.target +Requires=profile.service +After=xorg.target profile.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/bash -cx '. $XDG_CONFIG_HOME/X11/xprofile && systemctl --user import-environment' + +[Install] +WantedBy=xorg.target diff --git a/.profile b/.profile index ae04a10..57db97f 100644 --- a/.profile +++ b/.profile @@ -43,18 +43,14 @@ export PATH="${PATH}:/sbin:/usr/sbin:$DOTFILES/scripts:$GOPATH/bin" exists() { which $@ 0<&- 1>/dev/null 2>/dev/null; } +if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && exists dbus-launch; then + eval $(dbus-launch --sh-syntax --exit-with-session) +fi + +# Execute this after updating dbus/systemd environment # Source secret keys and values into environment if [ -f "$XDG_CONFIG_HOME/secrets" ]; then set -o allexport source $XDG_CONFIG_HOME/secrets set +o allexport fi - -# Start a dbus session daemon for programs that require it -if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && exists dbus-launch; then - eval $(dbus-launch --sh-syntax --exit-with-session) - dbus-update-activation-environment --systemd \ - DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY \ - XDG_SEAT_PATH -fi - diff --git a/aliases b/aliases index 9f9f247..db47f21 100644 --- a/aliases +++ b/aliases @@ -105,7 +105,9 @@ mcd(){ mkdir -p -- $@ && cd -- $@; } randstr() { tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w $1 | head -n 1; } # System aliases -alias s="sudo systemctl" +alias sc="systemctl" +alias ssc="sudo systemctl" +alias scu="systemctl --user" alias j=journalctl alias ps='ps aux' alias catn='tail -n +1 --' @@ -290,8 +292,8 @@ alias xinitrc="$EDITOR $XDG_CONFIG_HOME/X11/xinitrc" alias xresources="$EDITOR $XDG_CONFIG_HOME/X11/xresources ; xrdb merge $XDG_CONFIG_HOME/X11/xresources" alias sshc="$EDITOR ~/.ssh/config" alias dotfiles="cd $DOTFILES" -alias i3c="$EDITOR $XDG_CONFIG_HOME/i3/config ; i3-msg restart" -alias polybarc="$EDITOR $XDG_CONFIG_HOME/polybar/config; killall -q polybar; while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done; exec polybar -r i3bar" +alias i3c="$EDITOR $XDG_CONFIG_HOME/i3/config; systemctl --user reload i3" +alias polybarc="$EDITOR $XDG_CONFIG_HOME/polybar/config; systemctl --user restart polybar@i3bar" alias sf=screenfetch alias nf=neofetch