You are not logged in.

#1 2019-12-02 17:12:22

Registered: 2014-09-22
Posts: 43

masking and automount units

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

and something like

ExecUpPost=/bin/sudo -u\#1000 /bin/sh -c 'echo $$ >$XDG_RUNTIME_DIR/ && 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/ && 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? yikes

Last edited by sharethewisdom (2019-12-02 17:13:59)


Board footer

Powered by FluxBB