如何在从suspend中恢复的时候执行脚本?

28 views
Skip to first unread message

宋为

unread,
May 25, 2015, 7:30:34 AM5/25/15
to sh...@googlegroups.com
之前说要找能装GNU/Linux的平板,现在已经买到了。

用debootstrap捏了个Ubuntu 15.04塞进去,跑得挺好。

现在遇到一个问题:一旦按电源键锁屏,Gnome3 就会挂起系统(我感觉这个逻辑
是正确的),再按电源键点亮屏幕时,goodix触屏驱动似乎会挂掉。

我发现卸载再加载一遍驱动模块就可以恢复触屏:
# modprobe -r goodix
# modprobe goodix

因而我想要一种方式,能够使得我的平板在从suspend中恢复的时候能够执行这两
条命令。

我在想,这版Ubuntu有systemd,能不能用systemd干这事儿?

Tolbkni Kao

unread,
May 25, 2015, 7:35:17 AM5/25/15
to sh...@googlegroups.com
试试自己写个脚本,处理 acpi events。

package: acpid / acpi-support-base


--
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN
---
您收到此邮件是因为您订阅了 Google 网上论坛的“Shanghai Linux User Group”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到shlug+un...@googlegroups.com
要查看更多选项,请访问 https://groups.google.com/d/optout

Gene Wu

unread,
May 25, 2015, 8:19:22 AM5/25/15
to sh...@googlegroups.com
买的什么型号?

发送自 Outlook




之前说要找能装GNU/Linux的平板,现在已经买到了。

用debootstrap捏了个Ubuntu 15.04塞进去,跑得挺好。

现在遇到一个问题:一旦按电源键锁屏,Gnome3 就会挂起系统(我感觉这个逻辑
是正确的),再按电源键点亮屏幕时,goodix触屏驱动似乎会挂掉。

我发现卸载再加载一遍驱动模块就可以恢复触屏:
# modprobe -r goodix
# modprobe goodix

因而我想要一种方式,能够使得我的平板在从suspend中恢复的时候能够执行这两
条命令。

我在想,这版Ubuntu有systemd,能不能用systemd干这事儿?

-- 
-- You received this message because you are subscribed to the Google Groups Shanghai Linux User Group group. To post to this group, send email to sh...@googlegroups.com. To unsubscribe from this group, send email to shlug+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/shlug?hl=zh-CN

依云

unread,
May 25, 2015, 10:17:05 AM5/25/15
to sh...@googlegroups.com
能。Arch 的 netctl-auto 就有这么搞。

这是我的 arp-sleep@.service 文件,用来在 suspend 之后恢复时删掉旧的手动
指定的 ARP 项的。

[Unit]
Description=arp sleep hook (clean gateway ARP entry)
Before=sleep.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=-/bin/sh -c "arp -d $$(ip route show | awk -vdev=%I '$$1 == \"default\" && $$5 == dev { print $$3; quit }')"

[Install]
WantedBy=sleep.target

--
Best regards,
lilydjwg

Linux Vim Python 我的博客:
http://lilydjwg.is-programmer.com/
--
A: Because it obfuscates the reading.
Q: Why is top posting so bad?

依云

unread,
May 25, 2015, 10:22:06 AM5/25/15
to sh...@googlegroups.com
On Mon, May 25, 2015 at 10:16:26PM +0800, 依云 wrote:
> 能。Arch 的 netctl-auto 就有这么搞。
>
> 这是我的 arp-sleep@.service 文件,用来在 suspend 之后恢复时删掉旧的手动
> 指定的 ARP 项的。
>
> [Unit]
> Description=arp sleep hook (clean gateway ARP entry)
> Before=sleep.target
> StopWhenUnneeded=yes
>
> [Service]
> Type=oneshot
> RemainAfterExit=yes
> ExecStart=-/bin/sh -c "arp -d $$(ip route show | awk -vdev=%I '$$1 == \"default\" && $$5 == dev { print $$3; quit }')"
>
> [Install]
> WantedBy=sleep.target

啊,弄错了:ExecStart 是在 suspend 前执行的;想要 resume 之后执行要把命
令写到 ExecStop。

我参照的是 netctl-sleep.service,不是 netctl-auto 的一部分(但是是
netctl 的一部分)。

Gator Liu

unread,
May 25, 2015, 10:05:04 PM5/25/15
to sh...@googlegroups.com

如果運氣好,不需要腳本
 /etc/pm/config.d/defaults
寫入
SUSPEND_MODULES
="goodix"

若不行,在寫個 script 放在 /etc/pm/sleep.d/ 
參考
https
://wiki.archlinux.org/index.php/Pm-utils


凉拌茶叶於 2015年5月25日星期一 UTC+8下午7時30分34秒寫道:
Reply all
Reply to author
Forward
0 new messages