zoukankan      html  css  js  c++  java
  • 拦截电源关机按键、自定义功能

    拦截电源关机按键、自定义功能
    #忽略gnome自带的电源管理
    sed -i "s/#HandlePowerKey=poweroff/HandlePowerKey=ignore/g" /etc/systemd/logind.conf
    systemctl status systemd-logind
    yum install acpid
    systemctl disable acpid
    #如果以systemctl start acpid方式启动acpid, /etc/acpi/actions/power.sh里的命令只有shutdown -h now能执行成功, 其它命令kill echo touch 均执行不成功, 只能以#acpid启动
    /etc/profile尾部添加
    ########################
    alreadyStart=$(ps -elf | grep acpid | grep -v grep | wc -l)
    if [  0 == ${alreadyStart} ] ; then
    acpid
    fi
    ########################
    /etc/acpi/actions/power.sh 删除所有行, 添加自定义关机按键功能, 什么都不写就是屏蔽掉了关机按键功能
    在此文件中添加如下几句,实现给screenserver进程发信号,让进程处理此信号(进程内部实现关闭屏幕、关闭操作系统)
    ########################
    #!/bin/sh
    PATH=/sbin:/bin:/usr/bin
    kill -12 $(ps -elf | grep screenserver | grep -v grep | awk '{print $4}')
    ########################
  • 相关阅读:
    python_day3
    python-day2
    python-day1
    【收集】安卓手机在市场占比的网址查找
    while循环
    switch多选择结构
    if选择结构
    顺序结构
    Scanner:求和 、求平均值
    Scanner:用户交互
  • 原文地址:https://www.cnblogs.com/LiuYanYGZ/p/9568912.html
Copyright © 2011-2022 走看看