GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Ridurre automaticamente la luminosità a batteria in Ubuntu 15.10?

Come posso ridurre automaticamente la luminosità quando scollego l'AC in Ubuntu 15.10?

Ho provato a modificare le impostazioni di dconf-editor come suggerito qui, https://askubuntu.com/a/312619/511925, ma non ci sono più tali impostazioni in Ubuntu 15.10.

Ho provato a installare Cuttlefish, ma non è disponibile per Ubuntu 15.10.

Qualche idea?

Risposta accettata:

Introduzione

Lo script seguente usa dbus e on_ac_power script di shell (che viene fornito per impostazione predefinita con Ubuntu) per verificare la presenza di un adattatore CA e imposta la luminosità in base ai valori impostati in $HOME/.auto-backlightrc file.

Installazione

Installazione tramite git tramite terminale:

  1. Esegui sudo apt-get install git per installare git
  2. Esegui mkdir $HOME/bin . Salta questo passaggio se $HOME/bin esiste già
  3. cd $HOME/bin
  4. Esegui git clone https://github.com/SergKolo/sergrep.git
  5. Lo script sarà in $HOME/bin/sergrep/auto-backlight.sh . Assicurati che lo script sia eseguibile con chmod +x $HOME/bin/sergrep/auto-backlight.sh
  6. Aggiungi lo script come applicazione di avvio. Cerca il menu delle applicazioni di avvio in Unity Dash o nella ricerca di Gnome. In alternativa, esegui gnome-session-properties comando nel terminale per avviare il menu. Aggiungi il percorso completo allo script come applicazione di avvio in modo che venga avviato ogni volta che accedi alla GUI.

In alternativa, puoi copiare e salvare il sorgente dello script da solo, chmod +x file e segui il passaggio n. 6 sopra descritto.

Per fare in modo che lo script si avvii automaticamente ogni volta che accedi a Gnome o Unity, usa l'utility Applicazioni di avvio.

NOTA :se vuoi che lo script imposti sempre la luminosità AC, decommenta anche l'istruzione else alle righe 60 e 61 , in particolare questa 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

Sorgente dello 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

Ubuntu
  1. script di avvio utorrent / esegui utorrent all'avvio – Ubuntu 14.04 / 14.10

  2. Installa automaticamente aggiornamenti e patch di sicurezza in Ubuntu

  3. Ubuntu:forzare l'esecuzione del comando al logout?

  4. Problema di luminosità di Ubuntu 14.04 (lenovo Z500)?

  5. Script:installa ownCloud su un VPS Ubuntu 12.04

2 modi per installare Android Studio in Ubuntu 20.04/Ubuntu 18.04

[Risolto] Ubuntu non ricorda le impostazioni di luminosità

Come registrare sessioni di terminale in Ubuntu

Aggiorna automaticamente Plex su Ubuntu 14.04+

Come monitorare le prestazioni di Ubuntu utilizzando Netdata

Ubuntu / Unity Allega Script al Launcher?