You are not logged in.

#1 2013-11-10 14:10:11

johannesg00
Member
Registered: 2010-11-30
Posts: 74

running script depending on AC adapter

Hi,

i wrote a little script /etc/powersave, which runs two other scripts to control my display backlight and so on, depending on the state of the power supply:

#!/bin/bash

case `cat /sys/class/power_supply/AC0/online` in
  0)
    /etc/powersave_offline;;
  1)
    /etc/powersave_online;;
esac

If i run the script manually everything works fine. To run the script at boot i created a systemd service file /etc/systemd/system/powersave.service:

[Unit]
Description=Powersave
After=gdm.service

[Service]
Type=oneshot
ExecStart=/etc/powersave
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

This works as expected, but when i log in to gnome, it changes the backlight again. Is there a way to run this script after logging in?

Last edited by johannesg00 (2013-11-10 14:10:45)

Offline

#2 2013-11-10 14:33:55

lagagnon
Member
From: an Island in the Pacific...
Registered: 2009-12-10
Posts: 1,087
Website

Re: running script depending on AC adapter

Put "sleep 15" at top of script?


Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.

Offline

#3 2013-11-11 16:04:15

johannesg00
Member
Registered: 2010-11-30
Posts: 74

Re: running script depending on AC adapter

hey wink

i think this would work, but when i turn of the laptop and forget to log in the next 15 seconds, the script would be executed to early.
Is there a nicer solution for this?

Offline

#4 2013-11-11 16:56:40

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: running script depending on AC adapter

I think that gnome is just funky in how it handles configurations.  So it may actually be gconf that is deciding that it is going to set a whole different backlight level.  You might want to look into having that set too along with the rest of the stuffs.  But this might actually fail if there is no gconf running when the script is executed.

Offline

#5 2013-11-16 14:40:27

dreadkopp
Member
Registered: 2013-11-13
Posts: 6

Re: running script depending on AC adapter

just put the script in /etc/gdm/PostLogin/ ... then it is fired up after you log in

Last edited by dreadkopp (2013-11-16 14:40:37)

Offline

Board footer

Powered by FluxBB