You are not logged in.
My logind.conf's HandleLidSwitch is set to suspend. When closing the lid and having a wireless connection to a certain public AP, I'd like to temporarily configure the system to the effect of setting HandleLidSwitch to "lock", and have it set back to suspend when disconnected from that AP.
I don't leave my laptop unattended for long, the goal is just to continue downloading stuff. So, I should probably do
sudo systemctl mask suspend.target
and something like
#/etc/netctl/some-profile
Interface=wlp2s0
Connection=wireless
Security=wpa
ESSID=some-access-point
ExecUpPost=/bin/sudo -u\#1000 /bin/sh -c 'echo $$ >$XDG_RUNTIME_DIR/lidclose.pid && acpi_listen | while read event; do [[ $event == button/lid\ close* ]] && loginctl lock-session; done || true'
ExecDownPost=/bin/sudo -u\#1000 /bin/sh -c 'read pid < $XDG_RUNTIME_DIR/lidclose.pid && kill $pid || true'
The above (probably) does not work, but you get the idea. My question is simple: is there a more elegant way to try to do this? (apart from changing the Exec lines to in stead write a script in a separate file)
Can we make better use of systemd features? Would you like to be able to automask a unit? Could automask units then be automasked?
Last edited by sharethewisdom (2019-12-02 17:13:59)
Offline