¿Cómo puedo reducir automáticamente el brillo cuando desconecto la CA en Ubuntu 15.10?
Intenté modificar la configuración de dconf-editor como se sugiere aquí, https://askubuntu.com/a/312619/511925, pero ya no existen tales configuraciones en Ubuntu 15.10.
Intenté instalar Cuttlefish, pero no está disponible para Ubuntu 15.10.
¿Alguna idea?
Respuesta aceptada:
Introducción
El siguiente script usa dbus
y on_ac_power
script de shell (que viene por defecto con Ubuntu) para sondear la presencia de un adaptador de CA y establece el brillo de acuerdo con los valores establecidos en $HOME/.auto-backlightrc
archivo.
Instalación usando git
a través de la terminal:
- Ejecute
sudo apt-get install git
para instalargit
- Ejecute
mkdir $HOME/bin
. Omita este paso si$HOME/bin
ya existe cd $HOME/bin
- Ejecute
git clone https://github.com/SergKolo/sergrep.git
- El script estará en
$HOME/bin/sergrep/auto-backlight.sh
. Asegúrese de que el script sea ejecutable conchmod +x $HOME/bin/sergrep/auto-backlight.sh
- Agregue el script como una aplicación de inicio. Busque el menú Aplicaciones de inicio en Unity Dash o en la búsqueda de Gnome. Alternativamente, ejecute
gnome-session-properties
comando en la terminal para iniciar el menú. Agregue la ruta completa al script como aplicación de inicio para que se inicie cada vez que inicie sesión en la GUI.
Alternativamente, puede copiar y guardar la fuente del script por sí mismo, chmod +x file
y siga el paso #6 descrito anteriormente.
Para hacer que el script se inicie automáticamente cada vez que inicie sesión en Gnome o Unity, utilice la utilidad de aplicaciones de inicio.
NOTA :si desea que la secuencia de comandos establezca siempre el brillo de CA también, elimine el comentario de la declaración else en las líneas 60 y 61, específicamente esta parte
# The two lines bellow are optional for
# setting brightness if on AC. remove #
# if you want to use these two
# else
# change_brightness $INCREASE
Fuente del script
#!/usr/bin/env bash
#
###########################################################
# Author: Serg Kolo , contact: [email protected]
# 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