mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-23 18:28:34 +02:00
systemd: tentative to manage session with systemd
To me, I think it was cleaner to have a parameter with the current display. This way, the session is specific to the current display. It seems BindsTo doesn't think this way.
This commit is contained in:
parent
d5b72851ec
commit
ae691bb025
20 changed files with 132 additions and 82 deletions
|
@ -19,11 +19,6 @@ Here some of the things you may be interested in:
|
|||
- It is modular. I am using `config` as a table to pass different
|
||||
things between "modules".
|
||||
|
||||
- In `rc/xrun.lua`, there is a `xrun` function which runs a program
|
||||
only if it is not already running. Instead of relying on tools like
|
||||
`ps`, it looks at the list of awesome clients and at the list of
|
||||
connected clients with `xwininfo`. Seems reliable.
|
||||
|
||||
- I use a light transparency effect to tell if a window has the focus
|
||||
or not. It needs a composite manager.
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
exec compton \
|
||||
--backend glx \
|
||||
--xrender-sync \
|
||||
--xrender-sync-fence \
|
||||
--vsync opengl-swc \
|
||||
--paint-on-overlay
|
|
@ -9,9 +9,6 @@ case $(hostname),$(autorandr --current --skip-options gamma) in
|
|||
*,*) dpi=96 ;;
|
||||
esac
|
||||
|
||||
# Get xsettingsd PID
|
||||
pid=$(xprop -name xsettingsd _NET_WM_PID 2> /dev/null | awk '{print $NF}')
|
||||
|
||||
change() {
|
||||
# Build xsettingsd.local
|
||||
{
|
||||
|
@ -23,11 +20,7 @@ change() {
|
|||
} > ~/.xsettingsd
|
||||
|
||||
# Signal xsettingsd
|
||||
if [ x"$pid" = x ]; then
|
||||
xsettingsd -c ~/.xsettingsd &
|
||||
else
|
||||
kill -HUP $pid
|
||||
fi
|
||||
systemctl --user reload xsettingsd@$(systemd-escape -- "$DISPLAY").service
|
||||
|
||||
# Also use xrdb for very old stuff (you know, LibreOffice)
|
||||
echo Xft.dpi: $dpi | xrdb -merge
|
||||
|
|
|
@ -42,9 +42,9 @@ case "$1" in
|
|||
xdotool key XF86AudioStop
|
||||
# Then, lock screen
|
||||
echo "$(date --rfc-3339=seconds) $me: lock: lock screen"
|
||||
pkill compton
|
||||
systemctl --user stop compton@$(systemd-escape -- "$DISPLAY").service
|
||||
i3lock -n -e -i $HOME/.cache/awesome/current-wallpaper.png -t -f
|
||||
~/.config/awesome/bin/compton &
|
||||
systemctl --user start compton@$(systemd-escape -- "$DISPLAY").service
|
||||
echo "$(date --rfc-3339=seconds) $me: lock: unlock screen"
|
||||
;;
|
||||
esac
|
||||
|
|
1
rc.lua
1
rc.lua
|
@ -61,7 +61,6 @@ config.hostname = awful.util.pread('uname -n'):gsub('\n', '')
|
|||
config.browser = "firefox"
|
||||
|
||||
-- Remaining modules
|
||||
loadrc("xrun") -- xrun function
|
||||
loadrc("appearance") -- theme and appearance settings
|
||||
loadrc("debug") -- debugging primitive `dbg()`
|
||||
|
||||
|
|
11
rc/start.lua
11
rc/start.lua
|
@ -1,11 +1,5 @@
|
|||
-- Start idempotent commands
|
||||
local execute = {
|
||||
-- Kill any running nm-applet
|
||||
"pkill nm-applet",
|
||||
-- Start PulseAudio
|
||||
"xset -b", -- Disable bell
|
||||
-- Enable numlock
|
||||
"numlockx on",
|
||||
-- Default browser
|
||||
"xdg-mime default " .. config.browser .. ".desktop " ..
|
||||
"x-scheme-handler/http " ..
|
||||
|
@ -17,8 +11,3 @@ local execute = {
|
|||
}
|
||||
|
||||
os.execute(table.concat(execute, ";"))
|
||||
|
||||
-- Spawn various X programs
|
||||
xrun("polkit-gnome-authentication-agent-1",
|
||||
"/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1")
|
||||
xrun("NetworkManager Applet", "nm-applet")
|
||||
|
|
36
rc/xrun.lua
36
rc/xrun.lua
|
@ -1,36 +0,0 @@
|
|||
-- run a command only if the client does not already exist
|
||||
|
||||
local xrun_now = function(name, cmd)
|
||||
-- Try first the list of clients from awesome (which is available
|
||||
-- only if awesome has fully started, therefore, this function
|
||||
-- should be run inside a 0 timer)
|
||||
local squid = { name, name:sub(1,1):upper() .. name:sub(2) }
|
||||
if awful.client.cycle(
|
||||
function(c)
|
||||
return awful.rules.match_any(c,
|
||||
{ name = squid,
|
||||
class = squid,
|
||||
instance = squid })
|
||||
end)() then
|
||||
return
|
||||
end
|
||||
|
||||
-- Not found, let's check with xwininfo. We can only check name but
|
||||
-- we can catch application without a window...
|
||||
if os.execute("xwininfo -name '" .. name .. "' > /dev/null 2> /dev/null") == 0 then
|
||||
return
|
||||
end
|
||||
awful.util.spawn(cmd or name, false)
|
||||
end
|
||||
|
||||
-- Run a command if not already running.
|
||||
xrun = function(name, cmd)
|
||||
-- We need to wait for awesome to be ready. Hence the timer.
|
||||
local stimer = timer { timeout = 0 }
|
||||
local run = function()
|
||||
stimer:stop()
|
||||
xrun_now(name, cmd)
|
||||
end
|
||||
stimer:add_signal("timeout", run)
|
||||
stimer:start()
|
||||
end
|
12
systemd/autorandr@.service
Normal file
12
systemd/autorandr@.service
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=Configure displays
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStart=/usr/bin/autorandr --change --default default
|
||||
Type=oneshot
|
||||
RemainAfterExit=false
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session@%i.target
|
12
systemd/awesome@.service
Normal file
12
systemd/awesome@.service
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=Awesome window manager
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStart=/usr/bin/awesome
|
||||
ExecStopPost=/bin/systemctl --user stop graphical-session@%i.target
|
||||
Restart=on-failure
|
||||
|
||||
[Install]
|
||||
RequiredBy=xsession@%i.target
|
14
systemd/compton@.service
Normal file
14
systemd/compton@.service
Normal file
|
@ -0,0 +1,14 @@
|
|||
[Unit]
|
||||
Description=Compositor for X11
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStart=/usr/bin/compton --backend glx \
|
||||
--xrender-sync \
|
||||
--xrender-sync-fence \
|
||||
--vsync opengl-swc \
|
||||
--paint-on-overlay
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session@%i.target
|
12
systemd/inputplug@.service
Normal file
12
systemd/inputplug@.service
Normal file
|
@ -0,0 +1,12 @@
|
|||
[Unit]
|
||||
Description=XInput event monitor
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStartPre=/usr/bin/setxkbmap us
|
||||
ExecStart=%h/bin/inputplug -0 -c %h/.config/awesome/bin/input-event
|
||||
Type=forking
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session@%i.target
|
13
systemd/misc-x@.service
Normal file
13
systemd/misc-x@.service
Normal file
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=Miscellaneous settings for X11
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStart=/usr/bin/xset -b
|
||||
ExecStart=/usr/bin/numlock on
|
||||
Type=oneshot
|
||||
RemainAfterExit=false
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session@%i.target
|
10
systemd/nm-applet@.service
Normal file
10
systemd/nm-applet@.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Network Manager applet
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStart=/usr/bin/nm-applet
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session@%i.target
|
10
systemd/policykit-agent@.service
Normal file
10
systemd/policykit-agent@.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=PolicyKit authentication agent
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStart=/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session@%i.target
|
10
systemd/redshift@.service
Normal file
10
systemd/redshift@.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Set color temperature
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStart=/usr/bin/redshift -l 2.35:48.87 -t 6500:3900
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session@%i.target
|
10
systemd/xiccd@.service
Normal file
10
systemd/xiccd@.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=X color management
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStart=/usr/bin/xiccd --edid
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session@%i.target
|
3
systemd/xsession@.target
Normal file
3
systemd/xsession@.target
Normal file
|
@ -0,0 +1,3 @@
|
|||
[Unit]
|
||||
Description=X session managed by systemd
|
||||
BindsTo=graphical-session@%i.target
|
10
systemd/xsettingsd@.service
Normal file
10
systemd/xsettingsd@.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=XSETTINGS daemon
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStart=/usr/bin/xsettingsd -c %h/.xsettingsd
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session@%i.target
|
10
systemd/xss-lock@.service
Normal file
10
systemd/xss-lock@.service
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Unit]
|
||||
Description=Manage X screen saver
|
||||
PartOf=graphical-session@%i.target
|
||||
|
||||
[Service]
|
||||
Environment=DISPLAY=%I
|
||||
ExecStart=%h/.config/awesome/bin/xss-lock start
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session@%i.target
|
14
xsession
14
xsession
|
@ -21,14 +21,6 @@ export QT_AUTO_SCREEN_SCALE_FACTOR=1
|
|||
|
||||
systemctl --user import-environment
|
||||
systemd-run -q --scope --user tmux start-server
|
||||
|
||||
autorandr --change
|
||||
~/.config/awesome/bin/xsettingsd-setup
|
||||
~/.config/awesome/bin/compton &
|
||||
~/.config/awesome/bin/xss-lock start &
|
||||
xiccd --edid &
|
||||
setxkbmap us
|
||||
inputplug -0 -c ~/.config/awesome/bin/input-event 2> /dev/null
|
||||
redshift -l 2.35:48.87 -t 6500:3900 2> /dev/null &
|
||||
|
||||
exec awesome
|
||||
mkdir -p ~/.config/systemd
|
||||
ln -nsf ~/.config/awesome/systemd ~/.config/systemd/user
|
||||
exec systemctl --user start --wait xsession@$(systemd-escape -- "$DISPLAY").target
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue