Bash script workaround for intel backlight problems

Hi all,
I have LXDE with kernel 2.6.30, xf86-video-intel-newest (2.8 rc) on my Samsung NC10, and like many people I have been unable to change the backlight settings in X with kms turned on.
I have tried the various solutions on the forum and none of them work for me, so here are two little bash scripts that use the setpci command to change the backlight.
Note 1: I have a little file .backlight in my home dir that I store the backlight setting because I don't know how to read the value back from the pci address. So if you use this script you need to do this first:
echo FF > ~/.backlight
Note 2: These scripts also requre bc from extra to do the hex conversion & maths.
sudo pacman -Sy bc
It's only 240 K in size, but if you are trying to keep the number of installed packages low, then you won't like this
Here is the package details from pacman:
Name : bc
Version : 1.06-5
URL : None
Licenses : GPL
Groups : None
Provides : None
Depends On : readline
Optional Deps : None
Required By : None
Conflicts With : bc-readline
Replaces : bc-readline
Installed Size : 240.00 K
Packager : Allan McRae <[email protected]>
Architecture : i686
Build Date : Sat 02 Aug 2008 14:18:04 IST
Install Date : Thu 25 Jun 2009 16:06:53 IST
Install Reason : Explicitly installed
Install Script : No
Description : An arbitrary precision calculator language
bc /usr/
bc /usr/bin/
bc /usr/bin/bc
bc /usr/bin/dc
bc /usr/share/
bc /usr/share/info/
bc /usr/share/info/bc.info
bc /usr/share/info/dc.info
bc /usr/share/man/
bc /usr/share/man/man1/
bc /usr/share/man/man1/bc.1.gz
bc /usr/share/man/man1/dc.1.gz
You also need to know the address of you graphics card:
lspci | grep Display
For me this returns:
00:02.1 Display controller: Intel Corporation Mobile 945GM/GMS/GME, 943/940GML Express Integrated Graphics Controller (rev 03)
This is needed for this command in the scripts:
sudo setpci -s 00:02.1 F4.B=$var3
Note the 00:02.1 is the address for my laptop screen, 00:02.0 is the address for the vga out controller for me.
Increase backlight:
#!/bin/bash
var1=`cat ~/.backlight`
var2=`echo "16 i $var1 F + p"|dc`
if (( ( "$var2" \> "-1") && ( "$var2" \< "256" ) ));
then
var3=`echo "10 i 16 o $var2 p"|dc`
echo $var3 > ~/.backlight
sudo setpci -s 00:02.1 F4.B=$var3
fi
Decrease backlight:
#!/bin/bash
var1=`cat ~/.backlight`
var2=`echo "16 i $var1 F - p"|dc`
if (( ( "$var2" \> "-1") && ( "$var2" \< "256" ) ));
then
var3=`echo "10 i 16 o $var2 p"|dc`
echo $var3 > ~/.backlight
sudo setpci -s 00:02.1 F4.B=$var3
fi
Obviously someone else can write a much smarter/better set of scripts than me, but I hope is can be of use for someone!
Edit:Here are my openbox bindings for the scripts:
<keybind key="XF86MonBrightnessUp">
<action name="Execute">
<command>~/bin/blightu.sh</command>
</action>
</keybind>
<keybind key="XF86MonBrightnessDown">
<action name="Execute">
<command>~/bin/blightd.sh</command>
</action>
</keybind>
Last edited by makimaki (2009-07-11 14:26:08)

FYI: The new xf86-video-intel (2.9) has just been released:
http://article.gmane.org/gmane.comp.fre … xorg/40733
According to the release announcement, the new driver fixes the backlight issue with KMS:
* Add support for BACKLIGHT property when using kernel modesetting
  (KMS). This allows backlight adjustment with programs such as
  "xbacklight -set <percentage>" or "xrandr --set BACKLIGHT <value>".

Similar Messages

  • Better workaround for the whine problem

    I have discovered a workaround for the commonly reported electronic whine in the MacBook Pro.
    As most will know, if you open PhotoBooth and run it in the background it will get rid of the whine. I also noticed that the same worked in ANY application that uses the iSight.
    So, looking around the Apple website for widgets I stumbled across this . . . .
    http://www.apple.com/downloads/dashboard/webcams/mirror.html
    It solves the problem!!!!! Runs in the background, in the Dashboard, takes up no resources also!!
    Regards,
    Tom

    Didn't read that whole thread on the issue did you?
    It also kills your battery life.
    The issue I don't believe is related to the CPU directly but is related to the overall power drain on the system..it seems anything that causes the system to use more power 'solves' the problem.

  • Scripting Workaround for Icons

    I am trying to find a  workaround for video in Bridge that does not display a thumbnail.  I can do a  screenshot and save as jpeg,  then set the jpeg and avi in a stack.   That way I get a thumbnail image if jpeg is on top.  Clicking on the  lower stack image brings the jpeg and avi to the preview pane where the  movie can be previewed.
    That is where I would like a workaround.  The jpeg takes up half the preview pane so the movie previews at one half the size.
    Is  there a way to have the jpeg suppressed in the preview pane so the avi  takes up the whole pane? 
    Or perhaps an easier route,  not having jpeg  and avi in a stack but when the jpeg, of same name as avi, is selected  the avi would play in preview without the jpeg showing?  This would be some kind of a refernce shift.  Click on image A (jpeg) and image B (avi) opens in preview.
    If someone could solve this, you would be a hero to a lot of Bridge users that get only an icon.
    p.s. CS5 displalys the old avi format as a thumb, but not the newer mpeg4 varieties.  Adobe has been of no help.
    Thanks

    I also have a T2i ... great camera.  Although I shoot in 30P most of the time (for increased low light capability), it is my understanding that, since we can now put multiple formats and frame rates on the timeline, when we export ... eh, "Share" the final product, the conversion will put things in the frame rate that we tell it to.  For me that means to make a custom setting for Compressor to target the 25fps or 24fps and simply do the Share to that preset.  In the end that would give you more of a "film-like" look that you may be looking for.  If you think about it, progressive recording (the "p" in 60p) is simply that many full frame "pictures" one after another.  If you want to take 60p down to 25p, the algorithm in the Share would simply ignore rougly every other frame.  You would actually get a cleaner, but still "film-look" approximation by targeting 30fps.  Since 30 divides into 60 evenly, it should look great.  I have convert this stuff to 24fps a lot, and to my eye, it looks pro.  Don't know if this helps.
    stephen

  • Workaround for Hotmail IMAP problems in Mail

    Am a new Mac user, migrating from the windows world, and I would like to share my experience with solving the issue Hotmail has with IMAP.
    I've been using hotmail for years, migrating from hotmail really is not an option, have too many resumes/accounts et al established with that ID to consider switching to another web presence. Yet, the problems that Mail has with Hotmail/Outlook was making me crazy. Kept getting unsecured SSL errors, inability to connect errors, and having to fruitlessly retype my hotmail password while trying to connect.
    Called Applecare and the technician recommended a variety of fixes, which proved to be unsuccessful.
    What did work, was going into hotmail on the web, and having hotmail forward all of my mail to my iCloud email address, disabling my hotmail account from Mail on my Mac mini and my iPhone 5S. Only issue I had was that old mail stored on the hotmail account was stuck there, so I just forwarded that stuff back to myself on my hotmail account and it was automagically forwarded to my iCloud account.
    The iCloud to Mail on the Mac and the iPhone connection is flawless and transparent.
    There are a couple of potential issues with this workaround that I can forsee:
         a) If either iCloud OR Hotmail have a maintenance outage/denial of service attack I will be unable to send/receive mail until they both recover.
         b) Risk of having Hotmail account close due to inactivity
              1) Either sign up for Hotmail plus at $20/year
                                 ~or~
              2) Set a recurring calendar notification to log into hotmail on the web every 6 months to avoid the 8 1/2 month hotmail account deactivation.
    This solution is a kludge, but it works.
    Chuck

    sorry to bump this, I'm completely stumped though! Any ideas from anyone?
    Kind Regards
    Mark
    Dangleberry Music - Instruments and Accessories Online
    http://www.dangleberrymusic.co.uk

  • Workaround for port 25 problem?

    I've been considering to switch from TimeWarnerCable to Verizon FIOS for a while, but I've hesitated so far because of port 25 blocking. I would like to continue to be able to send through SMTP from my work email account, which only allows port 25 (apparently because of the spam new filter software our IT people run on on the server).
    Reading the messages on this board, I believe that I should be able to cirvumvent the problem by doing the following (once I have Verizon Fios):
    - Create a personality for the verizon.net email account in my mail program (I use Eudora);
    - set the verizon.net personality (or any other email address that allows alternative ports) as the "relay personality";
    - configure the work email personality to use the relay personality to send email;
    - If I am not mistaken, the email will then actually be sent through the verizon.net account, but it will look as if it came from my work account.
    Could someone please confirm that this would work? I'm really eager to switch to Verizon FIOS, and I hope this is not going to be a disappointment because of the email issue. This is your chance to win a customer ;-)
    Thanks,
    Martin

    Hi Martin, thanks for the question.  The answer will really depend on the email program you are using.  For residential accounts, we use port 587 for outgoing email purposes.  If that will not work for your employer, you may be able to setup a workaround. 
    In order to do this, you would need to configure your email program to accept emails in from your work account, and then to send out using the Verizon.net account.  Most programs allow a “Reply To” option to be configured, which you will need to set for your work email address.  In essence, this will allow you to send email out but still be replied to your work email address.
    You will still need to configure the outgoing portion of the email account to be sent over port 587, but this should not have any effect since you’re not sending through your employer’s systems.
    Thanks.
    Karl
    Verizon Support
    Notice: Content posted by Verizon employees is meant to be informational and does not supersede or change the Verizon Forums User Guidelines or Terms or Service, or your Customer Agreement Terms and Conditions or Plan.

  • [SOLVED] Bash Script checking for mail

    I have come up with this forsaken script...
    #!/bin/bash
    while :
    do
    NEWMAIL=$(curl -su "You'd wish." https://mail.google.com/mail/feed/atom | grep fullcount | cut -d ">" -f 2 | cut -d "<" -f 1)
    echo $NEWMAIL
    notify-send "Gmail" "You have $NEWMAIL new mails!"
    sleep 10s
    done
    It does get the number of new mails perfectly fine - I'm sure there is a better method with cut... -, and it echos the number, but notify-send does not seem to work. From what I've read I need to set the environmental variable or something like that. Yeah, no clue. Any hint is appreciated.
    Last edited by ThunderRush (2013-02-05 14:38:15)

    I tried that aesiris, of course with some gnome things, but it did not work either.
    And for jason: It's okay, thank you again for your help.
    I will see what else I can do, and will post a solution if I find one - which I doubt.
    What other alternatives to notify-send are there? Not a whole popup, but something more subtle?
    #EDIT
    As always, my own stupidity.
    Since I had absolutely no right set on the file, since the password is there in clear text, ist had the Permissions 111.
    But - gnome did not belong to my root.
    ps aux | grep gnome
    And I always started it as sudo, as root. So I changed the ownership to my user...
    sudo chown thunderuser gmailcheck
    and set the rights to 500. So I can execute and read it.
    And it finally worked. Thanks again.
    Last edited by ThunderRush (2013-02-05 14:37:53)

  • Finally, a Workaround for the JITTER PROBLEM

    OK, after ******* around (wonder if Apple's naughty-check will allow "*******") for many hours, burning many coasters, I have figured out a way to use iDVD, with its truly lovely menus, and beat that unfortunate problem the encoder has with jittery video. These videos always worked fine if I encoded them with Toast, but were very jittery (jiggly?) in spots if I encoded them with iDVD, even if I burned a disc image from Toast. The solution I came up with is one of two things:
    1. The video started out as something I extracted with Toast; I tried saving it as a Progressive thing, rather than an interlaced thing.
    2. I bought Toast 7, thinking that its new selectable menus would probably get me by; they are UGLY, UGLY, UGLY, can't use them to represent your portfolio. BUT, after adding all the movies to the Toast window, I noticed the "export" button below, exported the movies (I think just to .dv format), loaded them into iDVD and the PROBLEM WAS SOLVED. Not sure what happens here; I don't think the movies I exported from Toast were ever encoded by it, but something about the export process fixed the jitter.
    Sorry I don't know which of these two it is (I did them both, and don't have time to whittle it down), but one or the other finally solved my problem. If anyone identifies which of these ideas was the solution, please post it...

    Perhaps if you posted in the Lion discussion rather than the How To Use These Forums discussion you will get a an answer. The Lion gurus hang out over there. https://discussions.apple.com/community/mac_os/mac_os_x_v10.7_lion

  • A possible workaround for C2D Airport problems?

    A collegue advised the other day to download iStumbler, a free application that seems to sit and monitor all connections coming in your Airport, also for Bluetooth, Bonjour, etc.
    Well, I did... and ever since this thing started to work seeing my Network wifi the airport bars has returned back to the maximum level and there has been no connection drops, re-connecting flawlessly after sleep.
    Its funny also how iStumbler is able to see more Network wifis than the Airport menu: I see 2, sometimes 3 connections that I never saw on the Airport menu.
    The signal is reported to be at 70% with a 13% noise. But working great!
    Can someone with Airport problems try this solution and see if it works too? Maybe we are into something?
    Regards,
    -- Carlos

    I had installed istumbler a couple of days ago it did seem to improve the signal for a period then the signal dropped back to the normal 4/5 bars.
    After your post I started istumbler again and found there was an update the purports to solve signal problems with core 2 Duo macs.
    I have updated and have full signal strength for last 5 minutes longer than ever before.
    Fingers crossed

  • Workaround for video pausing problem

    I too was suffering from the problem where my videos would freeze every 30 or so seconds and then continue playing without sound. I figured out that running the video forward and backward by 5 sec. would let it keep playing for another 30s or so. Last night I discovered that simply pressing the center button twice after it pauses will allow it to keep playing without any more pauses. If you jog the video forwards or backwards then it will start pausing again.
    Hope this helps

    My experience with my files is that it stops the pausing until the next time you jog the video forwards or backwards. In my case I'm watching a TV series with 30 minute episodes. When an episode starts I run the video ahead 1:30 and then 30 seconds later it pauses. I then hit the center button twice and the video plays fine for the rest of the episode.

  • I just switched to iTunes 11.0.4. Is there a workaround for this sorting problem?

    Four bug fixes in, how can iTunes still not be displaying movies properly? When I look at the movies in my playlist in Grid View (sort by Title), the movies display at random. Plus, what does "Title" mean? There's no "title" listing in the Get Info.
    I'm about to switch back to iTunes 10, but I thought I'd post this in case there's a reason iTunes 11 is acting the way it is.

    Hi,
    Had not noticed this before! In Sort you can Sort by Tile but as you say you don"t have "Title' when you look at Get Info.
    This is appears to be a wrong labelling issue - "Title" is really "Name".
    Jim

  • XFI Extreme Music workaround for hanging and lock

    Well I think I found a workaround for all the problems with my new XFI XM card.
    I uninstalled it by activating a System Restore point to just before I installed the drivers with the Installation CD.
    Then I rebooted and when the Add New Hardware prompt popped up as it detected the installed XFI card I made sure my XFI install disk was in the dri've and went through the wizard. It located the drivers it needed on the install disk. Finished the installation and rebooted.
    Been running my system ever since, bout 0 hours now, also played Rise of Legends for about 2 hours straight (and if anyone knows how buggy ROL can be, thats no small feat), ran Itunes, all the normal stuff I do and not one glitch or hangup since. Even with about 50+ units duking it out in ROL I had momentary spots where the sounds seemed to bleed together but hey, with all that stuff going on and no lockup or BOOM BOOM BOOM starting up non stop, I'm a happy camper.
    Granted I didn't install any of the other fancy software from the install disk, but this is much better, at least it works with no locku
    ps.
    Hope this maybe helps anyone else who at least wants a functional system.
    Have a good one.

    Hi KokChoy, thanks for the reply. The reason I am asking is that others seem to be having the same issue with the Vista CD available online and seems to relate only to the extrememusic. Has the CD available online been updated since release It appears as though the online CD is for all XFI cards (except extreme audio). I was under the assumption that this would be the same CD which was distributed through retail with Xfi product's. The CD which I received with my extremegamer does have the drivers for the extrememusic as I pointed vista to the CD to search for drivers and it did indeed locate and install as an extrememusic.
    Not meaning to sound rude so I appologize in advance if I do but upon researching this I have found a number of posts but they all seem to contain "may not", "might", "should" or something similar. I was hoping to get some form of official response about the status of the install CD and specifically the extrememusic before ordering and paying shipping and handling for something which may end up being of no use to me.
    Thanks.

  • [SOLVED] problem with spaces and ls command in bash script

    I am going mad with a bash script I am trying to finish. The ls command is driving me mad with spaces in path names. This is the portion of my script that is giving me trouble:
    HOMEDIR="/home/panos/Web Site"
    for file in $(find "$HOMEDIR" -type f)
    do
    if [ "$(dateDiff -d $(ls -lh "$file" | awk '{ print $6 }') "$(date +%F)")" -gt 30 ];
    then echo -e "File $file is $(dateDiff -d $(ls -lh "$file" | awk '{ print $6 }') "$(date +%F)") old\r" >> /home/panos/scripts/temp;
    fi
    done
    The dateDiff() function is defined earlier and the script works fine when I change the HOMEDIR variable to a path where there are no spaces in directory and file names. I have isolated the problem to the ls command, so a simpler code sample that also doesn't work correctly with path names with spaces is this:
    #!/bin/bash
    HOMEDIR="/home/panos/test dir"
    for file in $(find "$HOMEDIR" -type f)
    do
    ls -lh "$file"
    done
    TIA
    Last edited by panosk (2009-11-08 21:55:31)

    oops, brain fart. *flushes with embarrassment*
    -- Edit --
    BTW, for this kind of thing, I usually do something like:
    find "$HOMEDIR" -type f | while read file ; do something with "$file" ; done
    Or put those in an array:
    IFS=$'\n' ; files=($(find "$HOMEDIR" -type f)) ; unset IFS
    for file in "${files[@]}" ; do something with "$file" ; done
    The later method is useful when elements of "${files[@]}" will be used multiple times across the script.
    Last edited by lolilolicon (2009-11-09 08:13:07)

  • Problem with "date -d" function in bash script. Leopard bug?

    I have this really nice rsync bash script that I use to make rotating snapshot backups of my different Ubuntu servers to a single backup server.
    I am now trying to use this same script on my Leopard machine, but it seems to have a serious problem with the following lines of code:
    lday=`date +'image-%Y-%m-%d-%H' -d '1 day ago'`
    lweek=`date +'image-%Y-%m-%d-%H' -d '1 week ago'`
    It generates the following error:
    date: illegal time format
    usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ...
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
    It's clear that it doesn't like the "-d '1 day ago'" part in my code.
    Is there a different way in Leopard to get yesterday's or last week's date in a bash script? Or is this a Leopard bug?
    Could someone please help me out? I've be trying to research this for the past 8 hours, but can't seem to find any solution to this problem.
    Thanks in advance.

    Is there a different way in Leopard to get yesterday's or last week's date in a bash script?
    date -v-1d
    date -v-7d

  • Iwl3945 and dhcpcd workaround - bash script

    I got tired of typing every command by hand all the time, so i made this simple bash script to do this for me...
    edit the script with your preferences and settings and run it as root. The script sets a static ip, and all the shizzle thats needed to have a workaround for the dhcp not working
    And im a newbie in bash programming, so please dont flame
    anywho, please give med feedback if theres something i could do different and better
    wlan script

    Correct me if I'm wrong, but you could simply add the rmmod / modprobe stuff and all that in PRE_UP='' in any of your netcfg profiles and the just run netcfg <profile>.

  • Bash script - sqllite insert problem

    So, I'm making a bash script that inserts a config file into a database, but I can't get it to work.
    This is my best attempt so far:
    name="bashrc"
    location="/home/user/.bashrc"
    content=`cat "$location"`
    sqlite3 testdb "insert into dbase values ('`echo $name`','`echo "$location"`','`echo "$content"`')"
    the table is
    create table dbase(name text, location text, data text)
    I had a hard time trying to figure out how I'd be able to get $variables to work (because of the quotes) and this echo style seems to work, but there seems to be no way to insert the config file into the database.
    plaintext files seem to work no problem, but when I'm trying to insert some config file, it spits out errors. (It seems like it's trying to execute the file somehow?)
    Last edited by initbox (2009-08-29 15:28:49)

    initbox wrote:I was thinking the single quotes were stopping bash from replacing $variables with the content, hence the echoes.
    your single quotes are inside a double quote, so to bash they're just another character in the string.
    I'm still getting an SQL syntax error, so bash is no longer getting in the way, but this thing is a true nightmare. What next? This turned out to be way harder than I expected, I'm just doing this as a "fun" learning experiment.
    Your error is probably because I was escaping the quotes for bash, and I should have been escaping them for sqlite. In sqlite, escaping a quote is done by doubling it, so ' is escaped to '' (that's two apostrephes side by side, not a double quote. Compare '' and ").
    This untested sed command might work:
    content = $(cat $location | sed "s/\'/\'\'/g")
    The \'s are escaping the quote from bash, what its really doing is replacing ' with ''.
    Dusty

Maybe you are looking for

  • Interim Bill

    Hello All, While doing a interim invoice, the system is generating an error "G/L account  does not exist". All the G/L are maintained. Can anyone guide what the issue could be. thanx.

  • How to save a word type file in the reader to read it there?

    I have files in .pdf format as well as some MS Word documents. Can anyone show me how do i need to proceed in order to ssave those files on my Sony PRS 650 Reader? Thank you kindly. Solved! Go to Solution.

  • Include in ABAP class for Workflow

    Hi, In order to use BOR macros inside ABAP class, (From SAP help) came to know that we need to use include <cntn02> . How to add this include to ABAP class for workflow? Regds, Akshay

  • IMac OSX 10.5 frozen desktop, mouse and keyboard still work. Won't let me open anything.

    iMac starts up as normal. Once it is on desktop, will not open anything. Have new snow leopard to install, put disk in and it pops up on desktop, however just like anything else I cannot click or open it. I have unplugged, restarted, used command-opt

  • Failed with deployejb

    Dear all, Trying to use the deployejb for an example in the Oracle8i Java componenets, I get this error: C:\Oracle\OraHome9iDS\jdev\mywork\JavaCompWS\Server>deployejb -republish -temp t emp -u scott -p tiger -s sess_iiop://localhost:2481:dev -verbose