# Suspend with custom action



## abishai (Sep 20, 2019)

I know about *hw.acpi.lid_switch_state=s3*, however I'm disappointed that laptop comes back unlocked. Here is script x11/xautolock invokes. I'd like to run it before S3 state as well. Is it possible?

```
dbus-send --session --dest=org.keepassxc.KeePassXC.MainWindow --type=method_call /keepassxc org.keepassxc.MainWindow.lockAllDatabases
i3lock  && sleep 1 && xset dpms force off
```


----------



## PMc (Sep 20, 2019)

Have a look at /etc/rc.suspend , it is supposed to add arbitrary commands to be run during suspend. 
But take care, it is run under a timeout of few seconds and will just terminate longer running commands.


----------

