在使用 dbus 时挂起之前运行脚本

ami*_*mir 6 d-bus suspend pm-utils

我有一个文件:/etc/pm/sleep.d/85rmNvidiaModule. 其中我有:

#!/bin/bash
case $1 in
    suspend)
        echo "Oh, this time we are doing a suspend to RAM. Cool!"
        sudo modprobe -r nvidia-uvm; optirun true
    ;;
    *)
        echo "Not doing anything useful"
    ;;
esac
Run Code Online (Sandbox Code Playgroud)

这在我使用时效果很好pm-suspend,但在我使用电源按钮暂停或执行以下操作时不起作用:

dbus-send --system --print-reply \ 
--dest=org.freedesktop.login1 /org/freedesktop/login1 \
"org.freedesktop.login1.Manager.Suspend" boolean:true
Run Code Online (Sandbox Code Playgroud)

所以问题是当我使用 gnome-shell 3.14.1 挂起时如何运行脚本。

此外,我使用的是 Debian GNU/Linux jessie/sid,并且大多数软件包都安装得非常干净。