From 69df55f6ce638b440e8b955a0b4531202f3a35dd Mon Sep 17 00:00:00 2001 From: FollieHiyuki Date: Mon, 12 Apr 2021 19:00:49 +0300 Subject: [PATCH] seatd: remove `loginctl` hardcoded --- deploy.sh | 2 +- home/.config/X11/xinitrc | 9 ++++++--- home/.config/nwg-launchers/nwgbar/bar.json | 4 ++-- home/.config/sway/config | 10 +++------- home/.local/bin/X11/animatedwall | 2 +- home/.local/bin/startwl | 11 ++++++++--- system/etc/doas.conf | 1 + system/etc/polkit-1/rules.d/49-nopasswd.rules | 10 ++++++++++ 8 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 system/etc/doas.conf create mode 100644 system/etc/polkit-1/rules.d/49-nopasswd.rules diff --git a/deploy.sh b/deploy.sh index 8368201..06bd2e7 100755 --- a/deploy.sh +++ b/deploy.sh @@ -108,7 +108,7 @@ cp -rfv ./home/.config/mpd/ ~/.config/mpd/ cp -rfv ./home/.config/mpDris2/ ~/.config/mpDris2/ cp -rfv ./home/.config/mpv/ ~/.config/mpv/ cp -rfv ./home/.config/ncmpcpp/ ~/.config/ncmpcpp/ -cp -rfv ./home/.config/neofetch/ ~/.config/neofetch/ +# cp -rfv ./home/.config/neofetch/ ~/.config/neofetch/ cp -rfv ./home/.config/newsboat/ ~/.config/newsboat/ cp -rfv ./home/.config/nnn/ ~/.config/nnn/ cp -rfv ./home/.config/npm/ ~/.config/npm/ diff --git a/home/.config/X11/xinitrc b/home/.config/X11/xinitrc index 35ad987..be26c1f 100644 --- a/home/.config/X11/xinitrc +++ b/home/.config/X11/xinitrc @@ -29,15 +29,18 @@ case $session in bspwm ) exec bspwm ;; spectrwm ) exec spectrwm -c ~/.config/spectrwm/spectrwm-nord.conf ;; exwm ) - # In case no elogind + # In case of using seatd. Flatpak apps won't work if [ -z "${XDG_RUNTIME_DIR}" ] then - export XDG_RUNTIME_DIR="/tmp/$(mktemp -d $(id -u ${USER})-runtime-XXXXXX)" + userid=$(id -u ${USER}) + export XDG_RUNTIME_DIR="$(mktemp -d /tmp/${userid}-runtime-XXXXXX)" if [ ! -d "${XDG_RUNTIME_DIR}" ] then - mkdir "${XDG_RUNTIME_DIR}" + mkdir -p "${XDG_RUNTIME_DIR}" chmod 0700 "${XDG_RUNTIME_DIR}" fi + # Assure we use seatd + # export LIBSEAT_BACKEND=seatd fi exec dbus-run-session emacs -mm --debug-init -l ~/.config/doom/exwm.el > "${XDG_RUNTIME_DIR}/exwm-$(date "+%Y-%m-%d").log" 2>&1 ;; * ) exec "$1" ;; diff --git a/home/.config/nwg-launchers/nwgbar/bar.json b/home/.config/nwg-launchers/nwgbar/bar.json index c4a870b..0e0d2fa 100644 --- a/home/.config/nwg-launchers/nwgbar/bar.json +++ b/home/.config/nwg-launchers/nwgbar/bar.json @@ -11,12 +11,12 @@ }, { "name": "Reboot", - "exec": "loginctl reboot", + "exec": "pkexec /usr/bin/reboot", "icon": "system-reboot" }, { "name": "Shutdown", - "exec": "loginctl poweroff", + "exec": "pkexec /usr/bin/poweroff", "icon": "system-shutdown" } ] diff --git a/home/.config/sway/config b/home/.config/sway/config index 4a0ed83..ac3e30b 100644 --- a/home/.config/sway/config +++ b/home/.config/sway/config @@ -70,7 +70,7 @@ input type:keyboard { xkb_options grp:rshift_toggle } -input * xkb_numlock enable +# input * xkb_numlock enable # _______ _____ _____ _____ # ___ |___ ___ /_______________ /______ _________ /_ @@ -229,12 +229,8 @@ bindsym $mod+Shift+r reload bindsym $mod+Mod1+q exec swaynag -t warning \ -m "Logout" \ -b "Exit session" "swaymsg exit" \ - -b "Suspend" "loginctl suspend" \ - -b "Hibernate" "loginctl hibernate" \ - -b "Hybrid sleep" "loginctl hybrid-sleep" \ - -b "Suspend then hibernate" "loginctl suspend-then-hibernate" \ - -b "Shutdown" "loginctl poweroff" \ - -b "Reboot" "loginctl reboot" + -b "Shutdown" "pkexec /usr/bin/poweroff" \ + -b "Reboot" "pkexec /usr/bin/reboot" # # Moving around: diff --git a/home/.local/bin/X11/animatedwall b/home/.local/bin/X11/animatedwall index 2d731e3..c3dc065 100755 --- a/home/.local/bin/X11/animatedwall +++ b/home/.local/bin/X11/animatedwall @@ -1,7 +1,7 @@ #!/bin/bash # require elogind or systemd -PIDFILE="/run/user/$UID/wall.pid" +PIDFILE="${XDG_RUNTIME_DIR}/wall.pid" declare -a PIDs diff --git a/home/.local/bin/startwl b/home/.local/bin/startwl index e65cb72..858fff2 100755 --- a/home/.local/bin/startwl +++ b/home/.local/bin/startwl @@ -2,15 +2,20 @@ # Start user dbus session alongside a Wayland compositor -# In case no elogind +# In case of using seatd (need the user to be in _seatd group) +# Flatpak apps will not work because of hardcoded /run/user/$UID if [ -z "${XDG_RUNTIME_DIR}" ] then - export XDG_RUNTIME_DIR="/tmp/$(mktemp -d $(id -u ${USER})-runtime-XXXXXX)" + userid=$(id -u ${USER}) + export XDG_RUNTIME_DIR="$(mktemp -d /tmp/${userid}-runtime-XXXXXX)" if [ ! -d "${XDG_RUNTIME_DIR}" ] then - mkdir "${XDG_RUNTIME_DIR}" + mkdir -p "${XDG_RUNTIME_DIR}" chmod 0700 "${XDG_RUNTIME_DIR}" fi + + # Assure we use seatd + # export LIBSEAT_BACKEND=seatd fi export XDG_SESSION_TYPE=wayland diff --git a/system/etc/doas.conf b/system/etc/doas.conf new file mode 100644 index 0000000..83418b4 --- /dev/null +++ b/system/etc/doas.conf @@ -0,0 +1 @@ +permit persist :wheel as root diff --git a/system/etc/polkit-1/rules.d/49-nopasswd.rules b/system/etc/polkit-1/rules.d/49-nopasswd.rules new file mode 100644 index 0000000..a475a35 --- /dev/null +++ b/system/etc/polkit-1/rules.d/49-nopasswd.rules @@ -0,0 +1,10 @@ +/* Allow running reboot, shutdown as normal user */ +/* of group wheel without sudo password */ +polkit.addRule(function(action, subject) { + if (action.id == "org.freedesktop.policykit.exec" && + (action.lookup("program") == "/usr/bin/reboot" || + action.lookup("program") == "/usr/bin/poweroff") && + subject.isInGroup("wheel")) { + return polkit.Result.YES; + } +});