1
0
mirror of https://github.com/frebib/dotfiles.git synced 2024-06-14 12:57:23 +00:00

systemd: default launch systemd apps in app.slice

Unless specified, units will launch in `app.slice` under the assumption
that they are foreground user applications.

Update i3 configuration to remove redundant app.slice definition.

Conform to unit naming of app-{name}-{random}.service as documented in
https://github.com/systemd/systemd/blob/master/docs/DESKTOP_ENVIRONMENTS.md#pre-defined-systemd-units

Signed-off-by: Joe Groocock <me@frebib.net>
This commit is contained in:
Joe Groocock 2020-08-18 12:49:31 +01:00
parent e2d1c57792
commit 9a04e70e77
Signed by: frebib
GPG Key ID: E0B16BEACFBB6A86
2 changed files with 24 additions and 16 deletions

View File

@ -132,15 +132,15 @@ popup_during_fullscreen smart
bindsym $mod+Shift+j reload
bindsym --release $mod+x exec xkill
bindsym $mod+c exec notify-send "Try again" "You meant \\\$mod+b"
bindsym $mod+b exec systemd-run-i3 -s app -c firefox
bindsym $mod+Return exec systemd-run-i3 -s app -n alacritty
bindsym $mod+Ctrl+Return exec systemd-run-i3 -s app -n alacritty --class floating
bindsym $mod+Shift+Return exec systemd-run-i3 -s app -n alacritty --working-directory "$(xcwd)"
bindsym $mod+Ctrl+Shift+Return exec systemd-run-i3 -s app -n alacritty --class floating --working-directory "$(xcwd)"
bindsym $mod+v exec systemd-run-i3 -s app -n alacritty -e sh -c "($SHELL -c $EDITOR || :) && $SHELL"
bindsym $mod+Ctrl+v exec systemd-run-i3 -s app -n alacritty --class floating -e sh -c "($SHELL -c $EDITOR || : ) && $SHELL"
bindsym $mod+b exec systemd-run-i3 -n firefox
bindsym $mod+Return exec systemd-run-i3 -n alacritty
bindsym $mod+Ctrl+Return exec systemd-run-i3 -n alacritty --class floating
bindsym $mod+Shift+Return exec systemd-run-i3 -n alacritty --working-directory "$(xcwd)"
bindsym $mod+Ctrl+Shift+Return exec systemd-run-i3 -n alacritty --class floating --working-directory "$(xcwd)"
bindsym $mod+v exec systemd-run-i3 -n alacritty -e sh -c "($SHELL -c $EDITOR || :) && $SHELL"
bindsym $mod+Ctrl+v exec systemd-run-i3 -n alacritty --class floating -e sh -c "($SHELL -c $EDITOR || : ) && $SHELL"
bindsym $mod+l exec dm-tool switch-to-greeter
bindsym $mod+space exec "pkill rofi; rofi -show run -sidebar-mode -terminal i3-sensible-terminal -normal-window -run-command 'systemd-run-i3 -s app -n {cmd}'"
bindsym $mod+space exec "pkill rofi; rofi -show run -sidebar-mode -terminal i3-sensible-terminal -normal-window -run-command 'systemd-run-i3 -n {cmd}'"
bindsym $mod+Shift+p exec rofi-pass --root $(grep path ~/.config/gopass/config.yml | sed -E 's|^.*fs\+file://||g' | tr '\n' ':') | sed 's/:$//g'
bindsym $mod+Shift+e exec "pkill rofi; rofi -show emoji -modi emoji -normal-window"
bindsym $mod+Shift+i exec rofi-fontawesome
@ -148,11 +148,11 @@ bindsym --release Print exec screenshot
bindsym --release $mod+Print exec screenshot --clip
bindsym --release Shift+Print exec screenshot --active
bindsym --release $mod+Shift+Print exec screenshot --active --clip
bindsym $mod+Shift+x exec systemd-run-i3 -s app -n i3-sensible-terminal --class floating-term --hold -e /bin/echo "$(xprop -id $(xdotool getactivewindow))"
bindsym $mod+Shift+x exec systemd-run-i3 -n i3-sensible-terminal --class floating-term --hold -e /bin/echo "$(xprop -id $(xdotool getactivewindow))"
bindsym $mod+$alt+space exec systemd-run-i3 -s background -n ~/.config/i3/cycleaudio.py && pkill -RTMIN+10 i3blocks
bindsym $mod+numbersign exec systemd-run-i3 -s app -n i3-sensible-terminal --hold -e sh -c 'xclip -o | gpg --decrypt 2>&1'
bindsym $mod+numbersign exec systemd-run-i3 -n i3-sensible-terminal --hold -e sh -c 'xclip -o | gpg --decrypt 2>&1'
bindsym $mod+r exec bash -c 'pwgen -snc 32 1 | tee >(xargs notify-send Generated\ password\:) | xclip -i -r'
bindsym $mod+g exec systemd-run-i3 -s app -n notify-send -c transfer "$(gist -PRpc)"
bindsym $mod+g exec systemd-run-i3 -n notify-send -c transfer "$(gist -PRpc)"
bindsym --release $mod+i exec systemd-run-i3 -s background -n sh -c 'sleep 0.5 && xdotool getactivewindow type --delay 250 "$(xclip -o -selection clipboard)"'
# Media player controls

View File

@ -1,12 +1,11 @@
#!/bin/bash -e
rand=$(tr -dc 'a-f0-9' < /dev/urandom | head -c 16)
rand=$(tr -dc 'a-f0-9' < /dev/urandom | head -c 8)
args=()
while getopts "u:s:e:d:cnw" opt
while getopts "s:e:d:cnw" opt
do case "$opt" in
u) args+=("--unit=$OPTARG-$rand");;
s) args+=("--slice=$OPTARG");;
s) slice="$OPTARG";;
e) args+=("--setenv=$OPTARG");;
d) args+=("--working-directory=$OPTARG");;
c) args+=("--scope");;
@ -17,4 +16,13 @@ do case "$opt" in
done
shift $((OPTIND-1))
exec systemd-run --user --collect --unit="$1-$rand" ${args[@]} -- "$@"
if [ -z "$slice" ]; then
slice=app
fi
exec systemd-run \
--user \
--collect \
--slice="$slice" \
--unit="$slice-$1-$rand" \
${args[@]} -- "$@"