Save backlight brightness settings across reboots, Gnome 3

The title pretty much says it all. I was wondering if anyone knows of a way to have gnome 3 to save the backlight brightness when you reboot. Once it boots back into gnome after a certain point the brightness would be restored to what you previous had it set to.

The current options are to set it to dim when idle, but that makes no difference here because when you unidle it goes back to what I had it set to, so that works properly.

The problem is when rebooting the brightness is set to the default 100%, and even the ati proprietary catalyst doesn’t remedy this, but I’m pretty sure in Windows 7 something sets it or sends a signal to the bios or something to retain the setting, but there is no brightness setting in the bios, so I was wondering if anyone knows of a script that might save the brightness and then restore it perhaps?

system is amd e350/radeon 6310, newly installed openSUSE 12.1 with Gnome 3, and the default radeon free driver.

BUMP

There has to be something out there, I’ve been looking a lot but haven’t had much luck, but I’ll be sure to post when I figure something out.

OK I went back to google but this is all I could really find, the first link basically does it and I’ll paste the code here to, but it doesn’t use the exact same layout as I have so I’m not sure what to make of it but it’s a good starting point:

https://lists.launchpad.net/ac100/msg00338.html

Hi,
I wrote a simple init script to save and restore backlight brightness between reboots (have taken urandom as base idea).

If some one wants to try it:

  • save the attached script in /etc/init.d and make it executable
  • create the wanted sym link in /etc/rc*.d (I suggest rcS.d/S55brightness rc0.d/S30brightness rc6.d/S30brightness)
  • create the directory /var/lib/backlight where brightenss value will be saved

all this as root naturally.

My two cents …

Marco

#! /bin/sh

BEGIN INIT INFO

Provides: brightness

Required-Start: $local_fs

Required-Stop: $local_fs

Default-Start: S

Default-Stop: 0 6

Short-Description: Save and restore brightness between restarts.

Description: This script saves the brightness between restarts.

It is called from the boot, halt and reboot scripts.

END INIT INFO

-c /dev/urandom ] || exit 0

PATH=/sbin:/bin
SAVEDFILE=/var/lib/backlight/brightness
. /lib/init/vars.sh

. /lib/lsb/init-functions

do_status () {
if -f $SAVEDFILE ] ; then
return 0
else
return 4
fi
}

case “$1” in
start|“”)
“$VERBOSE” = no ] || log_action_begin_msg “Restoring backlight brightness”
cat “$SAVEDFILE” >/sys/class/backlight/pwm-backlight/brightness 2>&1
ES=$?
“$VERBOSE” = no ] || log_action_end_msg $ES
;;
stop)

Carry a brightness from shut-down to start-up;

“$VERBOSE” = no ] || log_action_begin_msg “Saving backlight brightness”
cat /sys/class/backlight/pwm-backlight/brightness > “$SAVEDFILE” 2>&1
ES=$?
“$VERBOSE” = no ] || log_action_end_msg $ES
;;
status)
do_status
exit $?
;;
restart|reload|force-reload)
echo “Error: argument ‘$1’ not supported” >&2
exit 3
;;
*)
echo “Usage: brightness start|stop” >&2
exit 3
;;
esac

:

This link mentions a good example that would work well if I know how to make a script read something from another script, if that makes sense, but I’m clueless:

Fedora 15 – HP DV6 Laptop Screen Brightness Workaround

Having started using Fedora and Gnome 3 I’ve encoutnered a number of issues with my HP DV6 Laptop. One of the biggest issues was that the brightness controls built in to the OS didn’t actually change the brightness of the backlight, so it was stuck on the lowest setting.

There are a lot of ideas of how to fix it on the ‘net and I tried xbrightness, xbacklight and 3-4 different ATI drivers before I found a shell script and modified it to suit. This is the result:

#!/bin/sh
clear
echo “Enter a brightness value (1-10)”
read brightness
echo $brightness > /sys/devices/virtual/backlight/acpi_video0/brightness
echo “Brightness set to $brightness.”

Simply save as a shell script (I used brightness.sh as the filename) and run it as a super user. Enter a value in between 1 and 10 (where 1 is 10% brightness and 10 is 100%) and press enter. This will set your backlight brightness. Unfortunately it doesn’t stay set between reboots, but I plan to find a way to save the current brightness to file and create another script to run at startup and set the brightness. I’m also hoping I can use a similar method to bind to the fn-f2 and fn-f3 commands to enable the keyboard controls.

Keep an eye out for that in the next week or two.

And this last link might just work but it still needs modified a bit, as it’s designed for modifying the backlight, AND saving and restoring it:
Script to set-up brightness of backlight in XFCE

Hello,
I have written script to set-up brightness of backlight in XFCE (it will probably works with any linux distribution and X). It is only editing number in /sys/class/backlight/acpi_video0/brightness. This script works good in command line, it will decrease/increase brightness by 1 degree, but I have different problem with that script.

When I make shortcuts in XFCE (Applications-> preferences-> keyboard → keyboard shortcuts tab) and associate commands bright -p / bright -m with keys for changing brightness on my laptop it works properly too, but bad things is, that on one press of key, it decrease or increase brightness by 2 degrees. In other words, this script is executed twice on one press of key. How to execute it only once on one press of key?

PS: I know, in XFCE exist plugin for regulating backlight brightness, but I didn’t found, how to drive it from command line (for keyboard) and it forgets last set value, so after reboot, backlight is back on maximum.

My script looks like that (If it help):

#!/bin/bash

Script for changing backlight brightness in /sys/class/backlight/acpi_video0/brightness

can take values 0-15, in real (my notebook) works only values 2-15

#IMPORTANT: you must have writing rights to /sys/…/brightness (I must solute it with visudo or something like that…)
#IMPORTANT: for proper work after reboot must exist directory .bright in your home directory and file last_bright in .bright directory

#reads content of brightness and save it into variable
BRIGHT=$(cat /sys/class/backlight/acpi_video0/brightness)

while getopts “pmlh” optname
do
case “$optname” in
“p”)
#Add more brightness
#BRIGHT++
BRIGHT=$(($BRIGHT+1))
#protect mechanism (BRIGHT must be lower or equal to 15)
if (($BRIGHT>15))
then
BRIGHT=$((15))
fi
;;
“m”)
#decrease brightness
#BRIGHT
BRIGHT=$(($BRIGHT-1))
#protect mechanism (BRIGHT must be bigger or equal to 2)
if (($BRIGHT<2))
then
BRIGHT=$((2))
fi
;;
“l”)
echo “Loading last value of brightness.”
#Load last value, saved in file last_bright
BRIGHT=$(cat $HOME/.bright/last_bright)
echo “Poslední hodnota bright je $BRIGHT”
;;
“h”)
echo "Help: "
echo “-p Increase brightness”
echo “-m Decrease brightness”
echo “-l Load last brightness value”
echo “-h This help”
echo “Programmed by: ElectricZero”
;;
“?”)
echo “Unkonwn argument, try bright -h for help”
;;
*)
# Should not occur
echo “Unknown error while processing options”
;;
esac
done
echo “Brightness set on $BRIGHT”
#Save variable BRIGHT into file brightness
echo $BRIGHT > /sys/class/backlight/acpi_video0/brightness
#Save variable BRIGHT into file last_bright
echo $BRIGHT > $HOME/.bright/last_bright

I’ll try that last one out just as soon as I figure out how to properly create startup scripts, and post back here. I’m hopeful.

Okay so I looked over that last one and did some reading about editing sudoers etc and it appears I need to do as suggested in that last script and add it to run as root via sudoers file, this is what I’ve done:

created the directory and file mentioned in home, i.e .bright and the empty file last_bright inside.

next I created a blank file /etc/init.d/save_brightness containing the last script which I’m putting here again for reference and chmod +x it


#!/bin/bash
# Script for changing backlight brightness in /sys/class/backlight/acpi_video0/brightness
# can take values 0-15, in real (my notebook) works only values 2-15

#IMPORTANT: you must have writing rights to /sys/.../brightness (I must solute it with visudo or something like that...)
#IMPORTANT: for proper work after reboot must exist directory .bright in your home directory and file last_bright in .bright directory 

#reads content of brightness and save it into variable
BRIGHT=$(cat /sys/class/backlight/acpi_video0/brightness)

while getopts "pmlh" optname
 do
  case "$optname" in
   "p")
    #Add more brightness
    #BRIGHT++
    BRIGHT=$(($BRIGHT+1))
    #protect mechanism (BRIGHT must be lower or equal to 15)
     if (($BRIGHT>15))
     then
        BRIGHT=$((15))
     fi
    ;;
   "m")
    #decrease brightness
    #BRIGHT--
    BRIGHT=$(($BRIGHT-1))
    #protect mechanism (BRIGHT must be bigger or equal to 2)
     if (($BRIGHT<2))
     then
        BRIGHT=$((2))
     fi	
    ;;
   "l")
    echo "Loading last value of brightness."
    #Load last value, saved in file last_bright
    BRIGHT=$(cat $HOME/.bright/last_bright)
    echo "Poslední hodnota bright je $BRIGHT"
    ;;
   "h")
     echo "Help: "
     echo "-p	Increase brightness"
     echo "-m	Decrease brightness"
     echo "-l	Load last brightness value"
     echo "-h	This help"
     echo "Programmed by: ElectricZero"
     ;;
    "?")
     echo "Unkonwn argument, try bright -h for help"
     ;;
    *)
    # Should not occur
    echo "Unknown error while processing options"
    ;;
  esac
done
echo "Brightness set on $BRIGHT"
#Save variable BRIGHT into file brightness
echo $BRIGHT > /sys/class/backlight/acpi_video0/brightness
#Save variable BRIGHT into file last_bright
echo $BRIGHT > $HOME/.bright/last_bright

Here I come to a hit and miss step where i believe I should be adding /sys/class/backlight/acpi_video0/brightness/sys/class/backlight/acpi_video0/brightness to my sudoers file so I’ve done for example:
su
EDITOR=gedit gnomesu visudo
and basically have this towards the end:


##
## Runas alias specification
##

l300lvl ALL=(root) NOPASSWD: /sys/class/backlight/acpi_video0/brightness

I then reboot and try to start the script via command line or yast>system services(runlevel) and in terminal i get:

/etc/init.d/save_brightness -p

/etc/init.d/save_brightness: line 3: /sys/class/backlight/acpi_video0/brightness: Permission denied
/etc/init.d/save_brightness: line 7: syntax error near unexpected token )' /etc/init.d/save_brightness: line 7: solute it with visudo or something like that…)’

in system services i receive:
/etc/init.d/save_brightness start returned 2 (invalid or excess arguments):

I was getting something different in runlevel/services but regardless terminal still says denied?

What am I missing, perhaps I need to be running as root instead of my user name, but if that’s the case I’m guessing my syntax needs changed on that line

Perhaps:

root ALL = (ALL) NOPASSWD: /sys/class/backlight/acpi_video0/brightness

Not sure I should just take chances in sudoers though… Any hints?

BUMP!

I’ve tried getting help from a couple people but haven’t had much luck, mostly they don’t know about suse. It seems I keep running into various permissions problems where suse handles permissions in a totally different manner than I am used to, and I’m not sure if it’s more secure this way or not, but a simple media player can’t even save files due to these barriers, so I was wondering if anyone had any enlightenment other than switching back to Ubuntu/Mint?

On 12/02/2011 04:46 AM, l300lvl wrote:
>
> BUMP!
>
> I’ve tried getting help from a couple people but haven’t had much luck,
> mostly they don’t know about suse. It seems I keep running into various
> permissions problems where suse handles permissions in a totally
> different manner than I am used to,

i have no permission problems…none at all…tell me, have you:

  • used chown or chmod to adjust permissions in order to be able to
    create, move, delete, copy or edit any file or directory?
  • logged into Gnome 3 as root?
  • in YaST > Security Center and Hardening configured secure file permissions
  • in YaST > Novell AppArmor, adjusted any settings?

> and I’m not sure if it’s more secure
> this way or not, but a simple media player can’t even save files due to
> these barriers

i’ve never seen that either, and i read that before i posted the several
questions above…

can you point me to the forum URL where you posted that problem…(i’d
like to review it)

> so I was wondering if anyone had any enlightenment other
> than switching back to Ubuntu/Mint?

you ask a gnome3 question and there just are not that many gnome3 users
here! and therefore not a lot of helpers! you might be better off asking
somewhere here: http://www.gnome.org/ [maybe you find out they know it
is broken…is there a bugzilla on it?]

of course, switching to any distro is always you option, and i
personally (and many of the others here) encourage all to use what works
for them!

but, you seem to be having problems that the longer time openSUSE
users/helpers are not having…so, i’m guessing that some of the
problems may be due to administration practices which might work on a
different distro, but not openSUSE…


DD http://tinyurl.com/DD-Caveat
openSUSE®, the “German Engineered Automobiles” of operating systems!

i have no permission problems…none at all…tell me, have you:

  • used chown or chmod to adjust permissions in order to be able to
    create, move, delete, copy or edit any file or directory?
  • logged into Gnome 3 as root?
  • in YaST > Security Center and Hardening configured secure file permissions
  • in YaST > Novell AppArmor, adjusted any settings?

I have used chmod and chown a number of times, mostly only on my home partition but for instance I did chmod on the script I posted above, but I can pretty much go through and find any files I’ve touched and none were system files except for when I did a chown on that home directory, which didn’t fix everything the way I had hoped, as ultimately Guayadeque for some reason gets denied write permissions for simple image files(album covers)

I dont even know HOW to log in to Gnome 3 as root.

I’ve touched nothing in yast>security center as I don’t understand most of it, and I don’t have App Armor anywhere I can find.

What I can say is, I disabled the firewall right away, just by opening yast>firewall and clicking disable. Hopefully that is allowed without needing to change file permissions afterwards.

i’ve never seen that either, and i read that before i posted the several
questions above…

can you point me to the forum URL where you posted that problem…(i’d
like to review it)

Gladly, it’s Guayadeque and I’ve built from svn, there were no build errors and I made sure all dependencies, libs/dev libs mostly, were installed.
saving album art doesnt work - Guayadeque Music Player

you ask a gnome3 question and there just are not that many gnome3 users
here! and therefore not a lot of helpers! you might be better off asking
somewhere here: GNOME [maybe you find out they know it
is broken…is there a bugzilla on it?]

of course, switching to any distro is always you option, and i
personally (and many of the others here) encourage all to use what works
for them!

but, you seem to be having problems that the longer time openSUSE
users/helpers are not having…so, i’m guessing that some of the
problems may be due to administration practices which might work on a
different distro, but not openSUSE.

I can agree that I am not the greatest linux sys admin but I don’t understand, and I’m willing to accept that it just may be beyond my understanding of linux, as to why file permissions/file system permissions and/or root permissions however you would say it, would vary so much from one DE to the next? Wouldn’t it be the same situation on kde?

On 12/02/2011 07:06 PM, l300lvl wrote:
>
> I have used chmod and chown a number of times, mostly only on my home
> partition but for instance I did chmod on the script I posted above, but
> I can pretty much go through and find any files I’ve touched and none
> were system files except for when I did a chown on that home directory,
> which didn’t fix everything the way I had hoped

that is what i’m talking about…i can’t remember the last time i had
to use either…why do you use them? what problem do you try to ‘fix’
by using either? and, why would there be any system files in your /home
directory??

>, as ultimately
> Guayadeque for some reason gets denied write permissions for simple
> image files(album covers)

so, tell me about /SDAthree/l300lvl/Music/Usher-Discography/Usher-8701/

where is it? (internal hard disk, usb disk, networked disk different
machine [accessed how?])

what is the file system in use?

is ‘SDAthree’ a partition on a drive? how is it mounted? is it
referenced in fstab? how?

please show me the user terminal in/output of


ls -halR /SDAthree/l300lvl/Music/Usher-Discography/


and, by the way as i look at what you posted to guayadeque.org


05:38:00 PM: Error: can't open file
'/SDAthree/l300lvl/Music/Usher-Discography/Usher-8701/cover.jpg' (error
13: Permission denied)
05:38:00 PM: Error: Can't load image from file
'/SDAthree/l300lvl/Music/Usher-Discography/Usher-8701/cover.jpg': file
does not exist.
05:38:00 PM: Error: Invalid cover file
'/SDAthree/l300lvl/Music/Usher-Discography/Usher-8701/cover.jpg'

i’m not 100% sure why the permission was denied other than what it says:
“file does not exist” and/or the file is “invalid” which, afaik has
nothing to do with “a simple media player can’t even save files due to
these barriers”… ???

> I dont even know HOW to log in to Gnome 3 as root.

good.

> I’ve touched nothing in yast>security center as I don’t understand most
> of it, and I don’t have App Armor anywhere I can find.

good.

> What I can say is, I disabled the firewall right away, just by opening
> yast>firewall and clicking disable. Hopefully that is allowed without
> needing to change file permissions afterwards.

why would you want to do that?

>> i’ve never seen that either, and i read that before i posted the several
>> questions above…
>>
>> can you point me to the forum URL where you posted that problem…(i’d
>> like to review it)
>>
>
> Gladly, it’s Guayadeque and I’ve built from svn, there were no build
> errors and I made sure all dependencies, libs/dev libs mostly, were
> installed.
> ‘saving album art doesnt work - Guayadeque Music Player’
> (http://tinyurl.com/7emfyyk)

i can see where you wrote on guayadeque.org “I posted on their forums
just now regarding permissions so hopefully I’ll get some results” but i
don’t actually see the post you refer to…where is it? wait! are you
referencing this thread?? this one with the subject “backlight
brightness”? where is the one with the subject “permissions problems”??

>
> I can agree that I am not the greatest linux sys admin

me either (there are, for SURE, a bunch of stuff i have no clue about…

> but I don’t
> understand, and I’m willing to accept that it just may be beyond my
> understanding of linux, as to why file permissions/file system
> permissions and/or root permissions however you would say it, would vary
> so much from one DE to the next?

no, i never said they vary from one Desktop Environment to the next…

in fact, as far as i know none of those things vary from one
distribution to the next…what varies is thing like … well, for
instance Ubuntu/Mint lock the user out of root, and require them to use
sudo…so, a user from there might come here and (i’ve seen it) try to
use sudo like they did back on an earlier system and fail…and
immediately start changing file permissions to allow them to
copy/edit/etc instead of becoming root and doing the task correctly
(correctly here)

and, suddenly they have a tangle of file permissions that block and
confound…

> Wouldn’t it be the same situation on kde?

i am not talking about the differences between KDE and Gnome, but rather
Debian (and derivative) and openSUSE…

file permissions are not set/enforced at the DE level but rather at the
OS level…


DD http://tinyurl.com/DD-Caveat
openSUSE®, the “German Engineered Automobiles” of operating systems!

that is what i’m talking about…i can’t remember the last time i had
to use either…why do you use them? what problem do you try to ‘fix’
by using either? and, why would there be any system files in your /home
directory??

Well for instance I used chown as well as chmod on /SDAthree which is a mount point for sda3, so perhaps that would be considered ‘system’, if you get me? sda3 is basically a partition I use for backup/storage, which is ext4 fs. I don’t know why I called it a home folder, as it isn’t home for my user, it just has the same name. It was a left over home partition from an old install that I deleted, I just kept that partition which is why I did a chown. My home directory is located elsewhere and is not related in any way to anything on sda3

so, tell me about /SDAthree/l300lvl/Music/Usher-Discography/Usher-8701/

where is it? (internal hard disk, usb disk, networked disk different
machine [accessed how?])

what is the file system in use?

is ‘SDAthree’ a partition on a drive? how is it mounted? is it
referenced in fstab? how?

please show me the user terminal in/output of
Code:

ls -halR /SDAthree/l300lvl/Music/Usher-Discography/

it’s on sda3, SDAthree is a mount point pointing to /dev/sda3. sda3 is ext4. i added it to fstab via:
http://forums.opensuse.org/english/get-technical-help-here/64-bit/468691-auto-mounting-partitions-boot-hd.html


~> ls -halR /SDAthree/l300lvl/Music/Usher-Discography/
/SDAthree/l300lvl/Music/Usher-Discography/:
total 28K
drwxr-xr-x   3 root root 4.0K Dec  2 14:12 .
drwxr-xr-x 258 root root  20K Dec  2 14:09 ..
drwxr-xr-x   2 root root 4.0K Dec  2 14:14 Usher-8701

/SDAthree/l300lvl/Music/Usher-Discography/Usher-8701:
total 93M
drwxr-xr-x 2 root root 4.0K Dec  2 14:14 .
drwxr-xr-x 3 root root 4.0K Dec  2 14:12 ..
-rw-r--r-- 1 root root 1.2M Apr 15  2011 10-usher-without_u_(interlude).mp3
-rw-r--r-- 1 root root 7.5M Apr 15  2011 11-usher-can_u_help_me.mp3
-rw-r--r-- 1 root root 8.5M Apr 15  2011 12-usher-how_do_i_say.mp3
-rw-r--r-- 1 root root 5.2M Apr 15  2011 13-usher-hottest_thing.mp3
-rw-r--r-- 1 root root 5.5M Apr 15  2011 14-usher-good_ol_ghetto.mp3
-rw-r--r-- 1 root root 4.6M Apr 15  2011 15-usher-u-turn.mp3
-rw-r--r-- 1 root root 5.7M Apr 15  2011 16-usher-t.t.p.mp3
-rw-r--r-- 1 root root 5.7M Apr 15  2011 17-usher-separated.mp3
-rw-r--r-- 1 root root 1.1M Apr 15  2011 1-usher-intro-lude_8701.mp3
-rw-r--r-- 1 root root 6.5M Apr 15  2011 2-usher-u_remind_me.mp3
-rw-r--r-- 1 root root 6.3M Apr 15  2011 3-usher-i_dont_know_(feat_p_diddy).mp3
-rw-r--r-- 1 root root 7.1M Apr 15  2011 4-usher-twork_it_out.mp3
-rw-r--r-- 1 root root 5.7M Apr 15  2011 5-usher-u_got_it_bad.mp3
-rw-r--r-- 1 root root 5.5M Apr 15  2011 6-usher-pop_ya_collar.mp3
-rw-r--r-- 1 root root 5.9M Apr 15  2011 7-usher-if_i_want_to.mp3
-rw-r--r-- 1 root root 5.5M Apr 15  2011 8-usher-i_cant_let_u_go.mp3
-rw-r--r-- 1 root root 6.0M Apr 15  2011 9-usher-u_dont_have_to_call.mp3
-rw-r--r-- 1 root root  18K Nov 30 17:55 cover.jpg

in the above cover.jpg exists as a result of running guayadeque as root.

i’m not 100% sure why the permission was denied other than what it says:
“file does not exist” and/or the file is “invalid” which, afaik has
nothing to do with “a simple media player can’t even save files due to
these barriers”… ???

I was frustrated. I don’t really understand what is going on.

> What I can say is, I disabled the firewall right away, just by opening
> yast>firewall and clicking disable. Hopefully that is allowed without
> needing to change file permissions afterwards.

why would you want to do that?

I saw firewall as an un-needed service. Would disabling it have any affect on me other than having less security via outside network traffic? I can live with it if I ‘need’ to, as it’s not a huge consumer of system resources, I was just accustomed to not having one running.

i can see where you wrote on guayadeque.org “I posted on their forums
just now regarding permissions so hopefully I’ll get some results” but i
don’t actually see the post you refer to…where is it? wait! are you
referencing this thread?? this one with the subject “backlight
brightness”? where is the one with the subject “permissions problems”??

I did not open a new thread with this specific problem as I have so many questions I felt best not to flood the forums, so I figured I’d bring it up in this topic hoping for insight but I was in no rush to open another thread… Now that this topic is so far off-topic, I see that I made the wrong decision.

You are right about root/running things as sudo being different on Mint/Ubuntu, as I have seen many instances in suse where running something as ‘sudo command’ it tells me something like this for example:

> dmidecode
Absolute path to ‘dmidecode’ is ‘/usr/sbin/dmidecode’, so running it may require superuser privileges (eg. root).

> sudo dmidecode
root’s password:
sudo: dmidecode: command not found

> su
Password:
/home/l300lvl # dmidecode

dmidecode 2.11

and it finally works, very confusing and not what I’m used to, but I want to learn. That is one of the reasons I made the switch to suse.

On 12/02/2011 09:36 PM, l300lvl wrote:
>
> Well for instance I used chown as well as chmod on /SDAthree which is a
> mount point for sda3, so perhaps that would be considered ‘system’, if
> you get me? sda3 is basically a partition I use for backup/storage,
> which is ext4 fs. I don’t know why I called it a home folder, as it
> isn’t home for my user, it just has the same name. It was a left over
> home partition from an old install that I deleted, I just kept that
> partition which is why I did a chown. My home directory is located
> elsewhere and is not related in any way to anything on sda3

ok, now we are making progress!

please show us the terminal input/output from


df -h
cat /proc/partitions
cat /etc/fstab
sudo /sbin/fdisk -l

copy/paste the in/output back to this thread using the instructions
here: http://goo.gl/i3wnr

>> ls -halR /SDAthree/l300lvl/Music/Usher-Discography/
>>
>
> it’s on sda3, SDAthree is a mount point pointing to /dev/sda3. sda3 is
> ext4.
> ~> ls -halR /SDAthree/l300lvl/Music/Usher-Discography/
> /SDAthree/l300lvl/Music/Usher-Discography/:
> total 28K
> drwxr-xr-x 3 root root 4.0K Dec 2 14:12 .
> drwxr-xr-x 258 root root 20K Dec 2 14:09 …
> drwxr-xr-x 2 root root 4.0K Dec 2 14:14 Usher-8701

so, now we see why the application can not save a file unless it is
running as root! do you see that “root root” on the line ending with one
“.” and “…”?

the two dot line refers to current directory
(/SDAthree/l300lvl/Music/Usher-Discography/) and the one dot line refers
to the directory directly above the current directory
(/SDAthree/l300lvl/Music/) and both of those directories are owned by
root, and only useable (read/write/execute) by root user!

which is exactly why the guayadeque can’t save to it when you run it
as yourself…

this is not a “permissions problem” it is an administrative problem…as
soon as you get the administration of this SDAthree directory ironed out
there will be no problem

> I saw firewall as an un-needed service. Would disabling it have any
> affect on me other than having less security via outside network
> traffic? I can live with it if I ‘need’ to, as it’s not a huge consumer
> of system resources, I was just accustomed to not having one running.

well, you do as you wish…i’ve turned off my firewall for a total of
about 15 minutes in the last ten years of so…and, that was spread out
among maybe a half dozen or less instances when i couldn’t figure out
what way causing my network to block traffic…i would turn off the
firewall, immediately try again what ever was failing and if it still
failed i immediately restarted the firewall…if it didn’t fail again i
also immediately restarted the firewall–and let it run while i tried to
think my way though what is was in the firewall which was protecting me
TOO good.

this can’t-save-a-file problem has nothing whatsoever to do with your
firewall…turn it back on and leave it on…please.

> I did not open a new thread with this specific problem as I have so
> many questions I felt best not to flood the forums,

i understand you reasoning, but unfortunately it is exactly opposite of
what is best for you, and the forum…

always put only one problem in each thread…that makes it easy for
answer givers, and you, to know exactly what problem is being
discussed…AND, it keeps the thread cleaner so that when folks google
in looking for (in this case) “backlight brightness settings” they don’t
get confused with a big long discussion on ‘permissions’…AND, the
person who googles in looking for “why can’t i save a file? it just says
(error 13: Permission denied)” won’t have to wade though brightness stuff…

see?

do not worry about “flooding the forums” we have lots of space and would
rather have one million individual clean threads with one problem each,
than have half that number with two or more problems each.

> so I figured I’d
> bring it up in this topic hoping for insight but I was in no rush to
> open another thread… Now that this topic is so far off-topic, I see
> that I made the wrong decision.
>
> You are right about root/running things as sudo being different on
> Mint/Ubuntu, [snip]
> dmidecode
> Absolute path to ‘dmidecode’ is ‘/usr/sbin/dmidecode’, so running it
> may require superuser privileges (eg. root).

right! sudo keeps your environment, and path…and, since /user/sbin
is not in your path, it is not in your sudo path…so, you need to be
root to do that…

>> su
> Password:
> /home/l300lvl # dmidecode
> # dmidecode 2.11
>
> and it finally works

yes but, to become root in openSUSE don’t use just “su” use “su -” the
long reason for that is somewhere in one of these:

http://tinyurl.com/ydbwssh
http://tinyurl.com/665h5ek

so, we are making progress…but i need to see the output of the above
commands to make the next move… (we are gonna move the mount point for
“SDAthree” to a place more in line with the “Linux Way” and give it the
correct owner and group…

tell me, is this a stand alone machine and you are the only user…or,
are there several users and all of them should have the ability to both
save, delete and listen to all the music in this /Music/ directory…

or, should the other users have a different directory and not be allowed
into yours…AND how about all the other space on this
leftover-home-renamed partition…is it all for only you…or also others?

i may not be back to this thread today…so . . .


DD http://tinyurl.com/DD-Caveat http://tinyurl.com/DD-Hardware
http://tinyurl.com/DD-Software
openSUSE®, the “German Engineered Automobiles” of operating systems!

~> df -h
Filesystem      Size  Used Avail Use% Mounted on
rootfs           41G  5.7G   31G  16% /
devtmpfs        3.8G  8.0K  3.8G   1% /dev
tmpfs           3.8G   80K  3.8G   1% /dev/shm
tmpfs           3.8G  724K  3.8G   1% /run
/dev/sda8        41G  5.7G   31G  16% /
tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup
tmpfs           3.8G  724K  3.8G   1% /var/lock
tmpfs           3.8G     0  3.8G   0% /media
tmpfs           3.8G  724K  3.8G   1% /var/run
/dev/sda7       152M   43M  101M  30% /boot
/dev/sda3       266G  251G  2.0G 100% /SDAthree
/dev/sda9        73G   30G   41G  43% /home
/dev/sda4        49G   36G   14G  73% /windows/C
l~> cat /proc/partitions
major minor  #blocks  name

   8        0  488386584 sda
   8        1   14647296 sda1
   8        2          1 sda2
   8        3  283274240 sda3
   8        4   51207168 sda4
   8        5    4200966 sda5
   8        6    8193118 sda6
   8        7     159744 sda7
   8        8   41945088 sda8
   8        9   76451840 sda9
~> cat /etc/fstab
/dev/disk/by-id/ata-ST95005620AS_5YX0A613-part5 swap                 swap       defaults              0 0
UUID=7c123884-0518-4472-891a-188bdf036212 /                    btrfs      defaults              1 1
/dev/disk/by-id/ata-ST95005620AS_5YX0A613-part7 /boot                ext4       acl,user_xattr        1 2
UUID=77c064c7-6079-4494-99f6-dab5460dcfac /home                btrfs      defaults              1 2
/dev/disk/by-id/ata-ST95005620AS_5YX0A613-part3 /SDAthree            ext4       acl,user_xattr        1 2
/dev/disk/by-id/ata-ST95005620AS_5YX0A613-part4 /windows/C           ntfs-3g    users,gid=users,fmask=133,dmask=022,locale=en_US.UTF-8 0 0
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
~> sudo /sbin/fdisk -l
root's password:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf6f6f6f6

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    29296639    14647296   83  Linux
/dev/sda2   *   706458375   976768064   135154845    5  Extended
/dev/sda3        37488640   604037119   283274240   83  Linux
/dev/sda4       604037120   706451455    51207168    7  HPFS/NTFS/exFAT
/dev/sda5       714860433   723262364     4200966   82  Linux swap / Solaris
/dev/sda6       723262428   739648664     8193118+  83  Linux
/dev/sda7       739649536   739969023      159744   83  Linux
/dev/sda8       739971072   823861247    41945088   83  Linux
/dev/sda9       823863296   976766975    76451840   83  Linux

Partition table entries are not in disk order

That almost seemed like a test to see if I would follow directions, but thanks for a refresher course on using code tags and bbcode in general.

so, now we see why the application can not save a file unless it is
running as root! do you see that “root root” on the line ending with one
“.” and “…”?

the two dot line refers to current directory
(/SDAthree/l300lvl/Music/Usher-Discography/) and the one dot line refers
to the directory directly above the current directory
(/SDAthree/l300lvl/Music/) and both of those directories are owned by
root, and only useable (read/write/execute) by root user!

which is exactly why the guayadeque can’t save to it when you run it
as yourself…

this is not a “permissions problem” it is an administrative problem…as
soon as you get the administration of this SDAthree directory ironed out
there will be no problem

I gather that chown is not something that would give me full ownership over all files then, or perhaps I should have ran -R. At any rate, I’m delighted to hear it isn’t the result of suse having different settings in place.

From now on, I’ll open a new thread. No doubt about it.

right! sudo keeps your environment, and path…and, since /user/sbin
is not in your path, it is not in your sudo path…so, you need to be
root to do that…

Makes sense. I knew there had to be a reason for it.

yes but, to become root in openSUSE don’t use just “su” use “su -” the
long reason for that is somewhere in one of these:

Become su in Terminal - HowTo
su or su - ???

Looks like a good read, I have it open and ready for later.

so, we are making progress…but i need to see the output of the above
commands to make the next move… (we are gonna move the mount point for
“SDAthree” to a place more in line with the “Linux Way” and give it the
correct owner and group…

tell me, is this a stand alone machine and you are the only user…or,
are there several users and all of them should have the ability to both
save, delete and listen to all the music in this /Music/ directory…

or, should the other users have a different directory and not be allowed
into yours…AND how about all the other space on this
leftover-home-renamed partition…is it all for only you…or also others?

i may not be back to this thread today…so . . .

I do thank you for all of your help. And maybe you’ll understand when I say, this is my drive, my machine, and no one elses lol. I don’t play nice when it comes to my lappy, and I don’t share. If someone else uses it, they use it under my name, they only use firefox, and I keep close watch on them.

I should be the only one to have access and add/remove files or folders from sda3 or any other linux fs on sda for that matter. If I need to I can always put it on the ntfs partition but Windows is only a novel idea I see being used for Games and the like.

I have my own /home partition as you’ll see. And if this will require any resizing of partitions in any way, I can make room somehow. I have my music backed up on an external (sata connected via a usb adapter) as well, but that’s only used for backups.

On 12/03/2011 04:16 PM, l300lvl wrote:
>
> ~> cat /etc/fstab
> UUID=[blahblah] / btrfs defaults 1 1
> UUID=[blahblah] /home btrfs defaults 1 2
>
> That almost seemed like a test to see if I would follow directions, but
> thanks for a refresher course on using code tags and bbcode in general.

no it wasn’t a test, it just saves a lot of my typing the instructions
out and results in more easily readable output…

i’ve started a long step-by-step which will let you reclaim SDAthree as
your own…but, i’m this minute out of time to finish it…

but imHo you have a problem much larger than the one which is requiring
you to run a media player as root…

and, that problem is btrfs, which i see you elected to use as both your
root partition and your home…

the problem is that btrfs is an optional use, EXPERIMENTAL file
system…while it is flaky it might not break for you…but if it
does, at this point in time there are NO tools available to repair the
file system if problems arise (in other words, you should expect data
loss! now, for me data loss and /home should never be too close to each
other!!

here are some recent quotes and their cites:

btrfs “it’s so fragile (IMO FAT is more stable) that it’s not worth
trying yet … not a single tool to recover data” cite:
http://tinyurl.com/bp2tfkq

http://forums.opensuse.org/english/get-technical-help-here/tumbleweed/467370-btrfs-unable-mount-after-power-shortage.html#post2401514

"it is EXTREMELY fragile.
You can lose entire partition because of power failure.

I’ve encountered 3 filesystem corruptions and lost my /home twice (but
I had partition backups of course!).

So even though I was excited about it … I wouldn’t recommend it yet.
I even discourage until fsck is available. OR You can end up with ugly
kernel error screen during system boot" cite: http://tinyurl.com/dxbftdf

“Root filesystem got full and hang. After restart (sysrq+reisub) cant
get it resize to fit max free space because of errors in btrfsck.” cite:
http://forums.opensuse.org/showthread.php?t=468801

while i’m out enjoying life i ask you to do some reading and thinking
about if maybe you wish you hadn’t elected to use btrfs, and maybe want
to change it to ext4…your decision on that will impact how and when
you solve the root ownership of SDAthree

and, on SDAthree i notice it is 100% full/used so what do you intend to
do about that? (delete some, maybe? or move some to a USB drive? or?)

i’m not asking you to take action on the full disk or the switch file
system type…just decided what you want…

of course, it IS your system and you can proceed anytime you wish–but
be sure and backup to an off machine and safe place, first!

you should do that now anyway, because if you wanna switch file system
type that will require partitioning and i always advise back up
prior to any partitioning.

gotta run.


DD http://tinyurl.com/DD-Caveat
openSUSE®, the “German Engineered Automobiles” of operating systems!

As for SDAthree, I do eventually plan on deleting it and resizing it.

After all of the reading and reading and reading I had done on chmod and chown, I decided to have another look at the directory that I was most worried about which was SDAthree/l300lvl/Music and what I realized is that I never ran chown recursively, and it became totaly obvious how I was failing to that regard.

As far as switching file systems, the whole reason I chose btrfs was to experiment and learn. I like the challenge and I also like the snapper efforts being made. Without anyone to test and use the file system, it seems safe to say that it would never mature. I would like to start doing bug reports and debugging of some kind, not just running from the problems. But for now, I still consider ext4 as a safer alternative, and may switch to it on this machine for the stability.

As I see it, I’m not as concerned as I was about the file permission problems any longer. My main concern is still the original focus of this topic, which is more specifically:
How to run a script at start-up as root?

On 12/05/2011 07:46 AM, l300lvl wrote:
> I’m not as concerned as I was about the file permission
> problems any longer.

-R is your answer there, like

chown -R [you]:users /SDAthre

but, i would also change its fstab line
from: <snip>/SDAthree ext4 acl,user_xattr<snip>
to: <snip>/SDAthree ext4 defaults<snip>

> How to run a script at start-up as root?

can’t help with that, sorry.


DD http://tinyurl.com/DD-Caveat
openSUSE®, the “German Engineered Automobiles” of operating systems!

Bump.

Perhaps I should just start a new topic with a more specific title?

I have discovered that the Sudo section in Yast shows the addition to sudoers and I tried changing the permissions using Sudo since it was more obvious as to what I was doing, but nothing I did ever got the script to run.

I was thinking, perhaps there is a way to create a script that does essentially this but a little less complicated. LIke something that would run cat and then echo the results somewhere, like this did, but then the problem is still getting it to read the results on startup, and then set the brightness to that, but perhaps it would be easier. For example, by figuring out a way to have a simple command set the brightness, instead of having the value written anywhere at startup, it would just grab the value from where it was saved on shutdown, and then run the command to set the brightness as that? If that makes sense, it seems like it would be simpler that way.

Well I have still have zero luck getting any of these methods to work. I tried the one of the script and even ran insserv on it to make sure everything was done correctly, and it doesn’t appear it’s ever trying to start it. I’m not sure why?

Tthe simplest thing I can think of is to get a script to run on shutdown, if I can do that, I can make that script save the setting somewhere, and then use it in combination with laptopmodetools. The hard part is figuring out how to get a script to run at shutdown, so I’ll open a new post regarding that.

I’m thinking it’s about time I give up on this pursuit and move on. I’ve tried multiple methods of getting things to run as root at startup under gnome 3 and have normally failed.

I learned theres a way to get pxexec to remember passwords which may work, but theres another problem. FIrst I have to figure out how to run a startup command under gnome 3, after login.

It would seem, even after disabling gnomes power management features, that gdm or some other perpetrator is resetting the backlight settings on logout/reboot. This is where I’ve gotten:

Install laptop-mode-tools >configure backlight settings of laptop mode:


su
cd /etc/laptop-mode/conf.d # ls
nano /lcd-brightness.conf

now we modify, first you enable the lcd-brightness config, by setting it to 1.


#
# Should laptop mode tools control LCD brightness?
#
CONTROL_BRIGHTNESS=1


#
# Commands to execute to set the brightness on your LCD
#
BATT_BRIGHTNESS_COMMAND="echo 0"
LM_AC_BRIGHTNESS_COMMAND="cat /var/lib/backlight/brightness"
NOLM_AC_BRIGHTNESS_COMMAND="echo 10"
BRIGHTNESS_OUTPUT="/sys/class/backlight/acpi_video0/brightness"

next youll see LM_AC_BRIGHTNESS_COMMAND=“cat /var/lib/backlight/brightness”
this is the command we run to restore the saved brightness. This part actually works, it’s just that something else contradicts it. You’ll need to create the /var/lib/backlight/brightness or even change it to another destination, but brightness is just an empty file which will contain the results of /sys/class/backlight/X/brightness which may be different for you as well.

Next we have to disable gnomes power management features as it conflicts obviously, wanting to set its own ‘default’ brightness on start-up/login/both-unlexx-disabled.

(sudo zypper in dconf-editor)
fire up dconf and head to:
org.gnome.settings-daemon.plugins.power>active and uncheck, close dconf

now we work on saving the backlight setting, so the easiest method I found was to use halt.local to run the command, which will then write the current backlight setting to our previously created /var/lib/backlight/brightness

# gnomesu gedit /etc/init.d/halt.local

now we add, on a new line:

cat "/sys/class/backlight/acpi_video0/brightness" >/var/lib/backlight/brightness

this may seem sloppy, and it probably would be considered so seeing as how it doesn’t work properly, but it does work. now we save and reboot.

sudo cat /var/lib/backlight/brightness

ah yes, a problem. you will now see that it’s probably set at the highest possible setting, which for me is 10. This means that halt did not run the command to write the value until after we were logged out, and I would guess either wrote the default X value, or the default gdm value, neither which will help us achieve the desired results.

and this is where i sit saying &$& &$&# *#&$

I have tried to many countless attempts to get something going with this, and as far as I see it, the best possible method would be to get someone to write a Gnome shell extension to save and then restore the backlight settings. This may actually be much easier to achieve, and I will no longer feel a need to pluck my eyes out through my ears.

Good luck to he whoever stumbles on this.

On 12/16/2011 06:16 AM, l300lvl wrote:
> multiple methods of getting things to run as root at startup under
> gnome 3

fall back, work around (no, i didn’t read the thread again to see if i
already suggested this):

  1. construct/save script into your path
  2. make script executable
  3. after boot, when you first notice backlight is not what you want
    a. press Alt and F2
    b. type “gnomesu [scriptName]”
    c. give root password when requested
  4. enjoy backlighting the way you want it

that way if you don’t notice the backlight is wrong, nothing happens.

btw, did you log a bug (no, i did not read the entire thread again to
see if you did or not)? http://tinyurl.com/nzhq7j


DD
openSUSE®, the “German Engineered Automobiles” of operating systems!

No I did not follow a bug, and even though I had made the decision to give up, I have had better results.

  1. I got startup scripts to work via gnome-session-properties I had tried this but most of my scripts were not running, no idea why, but I tried simpler commands and they indeed run.
    this led to me finding another command to set the brightness, aka:
  2. gsd-backlight-helper : I found a few resources on this but after running --help I figured out it’s simple and useful. this link has more information on it:
    Linux Mint Forums • View topic - Mint 12 Tips & Tricks Guide (updated Dec 14) section 1m

# pkexec /usr/lib/gnome-settings-daemon-3.0/gsd-backlight-helper --help
Usage:
  gsd-backlight-helper [OPTION...]

GNOME Settings Daemon Backlight Helper

Help Options:
  -h, --help               Show help options

Application Options:
  --set-brightness         Set the current brightness
  --get-brightness         Get the current brightness
  --get-max-brightness     Get the number of brightness levels supported

so using gsd-backlight-helper, I should be able to construct a script which will grab the current brightness using pkexec, which we will also use to set it:

pkexec /usr/lib/gnome-settings-daemon-3.0/gsd-backlight-helper --get-brightness

i will use gnome-session-properties to run the script to set the brightness, once we create this.

i’m going to try using halt.local to grab the brightness, it should work this way, and hopefully only save the brightness of the current user lol

so far using gnome-session-properties it successfully sets the brightness after logging in, but one thing to remember was I had to disable the ac-idle setting in dconf-editor like we did in my last post. Only this time I have re-enabled the power management, as the only conflict is that the brightness dimming causes brightness to reset to max, this can be solved using sleep but I like disabling the dimming so:

org.gnome.settings-daemon.plugins.power>idle-dim-ac(and/or battery if you prefer, but using the Settings>Screen tool only seems to disable one part which may be a bug, so we use dconf.

i’ll post more later

Hi
You can use the gesettings command to set the schema keys, for example;


gsettings list-keys org.gnome.settings-daemon.plugins.power

gsettings get org.gnome.settings-daemon.plugins.power idle-dim-battery

There is also an overrides file in /usr/share/glib-2.0/schemas/ called
openSUSE-branding.gschema.override.


Cheers Malcolm °¿° (Linux Counter #276890)
openSUSE 11.4 (x86_64) Kernel 2.6.37.6-0.9-desktop
up 3 days 4:10, 3 users, load average: 0.02, 0.12, 0.19
GPU GeForce 8600 GTS Silent - Driver Version: 290.10