在Ubuntu 15.10中自动降低电池亮度?

在Ubuntu 15.10中拔下AC时如何自动降低亮度?

我尝试按照此处的建议修改dconf-editor设置, https: //askubuntu.com/a/312619/511925,但在Ubuntu 15.10中不再有这样的设置。

我尝试安装墨鱼,但它不适用于Ubuntu 15.10。

有任何想法吗?

介绍

下面的脚本使用dbuson_ac_power shell脚本(默认情况下带有Ubuntu)来轮询是否存在交流适配器,并根据$HOME/.auto-backlightrc文件中设置的值设置亮度。

安装

使用git通过终端安装:

  1. 运行sudo apt-get install git来安装git
  2. 运行mkdir $HOME/bin 。 如果$HOME/bin已经存在,请跳过此步骤
  3. cd $HOME/bin
  4. 运行git clone https://github.com/SergKolo/sergrep.git
  5. 该脚本将位于$HOME/bin/sergrep/auto-backlight.sh 。 使用chmod +x $HOME/bin/sergrep/auto-backlight.sh确保脚本可执行
  6. 将脚本添加为启动应用程序。 在Unity Dash或Gnome搜索中查找“启动应用程序”菜单。 或者,在终端中运行gnome-session-properties命令以启动菜单。 将脚本的完整路径添加为启动应用程序,以便每次登录GUI时都会启动它。

或者,您可以自己复制和保存脚本源, chmod +x file ,并完成上述步骤#6。

要在每次登录Gnome或Unity时自动启动脚本,请使用“ 启动应用程序”实用程序。

注意 :如果您希望脚本始终设置AC亮度,请取消注释第60和61行上的else语句,特别是此部分

  # The two lines bellow are optional for # setting brightness if on AC. remove # # if you want to use these two # else # change_brightness $INCREASE 

脚本来源

 #!/usr/bin/env bash # ########################################################### # Author: Serg Kolo , contact: 1047481448@qq.com # Date: February 26 2016 # Purpose: Brightness control that polls for # ac adapter presence. Uses # Dependencies: on_ac_power script, dbus, Unity/Gnome # Written for: https://askubuntu.com/q/739617/295286 # Tested on: Ubuntu 14.04 LTS ########################################################### # Copyright: Serg Kolo , 2016 # # Permission to use, copy, modify, and distribute this software is hereby granted # without fee, provided that the copyright notice above and this permission statement # appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # uncomment the line bellow for debugging #set -x ARGV0="$0" ARGC=$# main() { # defaults local DISPLAY=:0 local DECREASE=30 local INCREASE=75 local RCFILE="$HOME/.auto-backlightrc" #--- # Check the settings if [ -f $RCFILE ] then source $RCFILE else create_rcfile $DECREASE $INCREASE fi #--- # now actually test if we're using ac adapter if ! on_ac_power then change_brightness $DECREASE # The two lines bellow are optional for # setting brightness if on AC. remove # # if you want to use these two # else # change_brightness $INCREASE fi } change_brightness() { dbus-send --session --print-reply\ --dest=org.gnome.SettingsDaemon.Power\ /org/gnome/SettingsDaemon/Power \ org.gnome.SettingsDaemon.Power.Screen.SetPercentage uint32:"$1" } create_rcfile() { echo "DECREASE="$1 > "$RCFILE" echo "INCREASE="$2 >> "$RCFILE" } while true do main sleep 0.25 done