The time now is Sat 07 Dec 2019, 02:15
All times are UTC - 4 |
Author |
Message |
johnywhy

Joined: 20 Aug 2011 Posts: 882
|
Posted: Wed 05 Sep 2018, 03:18 Post subject:
Simple Brightness Slider Subject description: For sys/class/backlight |
|
Update: new streamlined style. Closes on click-away:
Original big version
Stays open until you close it.
both scripts below.
i got tired of using heavy 'Power Manager' background services, when all i wanted was to adjust my screen brightness.
I started by using a simple command to adjust my brightness:
Code: | echo 10000000 > /sys/class/backlight/intel_backlight/brightness |
Then i made this lovely brightness slider. Works like a dream. It will auto-scale to the max brightness of your backlight. Small footprint while running, leaves nothing running in the background when you close it.
Will only work if you have the lightweight yad, and if the above command (or something similar) will adjust the brightness on your OS.
To understand the basic function, and to ensure you have yad, try this at a command-line:
Code: | yad --scale --print-partial |
Streamline script:
Code: | #!/bin/sh
BrPath='/sys/class/backlight/intel_backlight/'
BrCur=`cat ${BrPath}brightness`
BrMax=`cat ${BrPath}max_brightness`
BrMin=$(( (BrMax + (100 - 1)) / 100)) # 100th max-brightness, rounded up to nearest integer
yad --scale --min-value $BrMin --max-value $BrMax --value $BrCur --print-partial --undecorated - --width 300 --fixed --sticky --mouse --on-top --escape-ok --no-buttons --hide-value --close-on-unfocus | while read BrNew
do echo "$BrNew" | sudo /usr/bin/tee ${BrPath}brightness
done
|
Big-Version script:
Code: |
#!/bin/sh
BrPath='/sys/class/backlight/intel_backlight/'
BrCur=`cat ${BrPath}brightness`
BrMax=`cat ${BrPath}max_brightness`
BrMin=$(( (BrMax + (100 - 1)) / 100)) # 100th max-brightness, rounded up to nearest integer
yad --scale --min-value $BrMin --max-value $BrMax --value $BrCur --print-partial --title 'Set brightnessradky's Dpup Stretch 7.5 (RC3)' --width 300 --fixed --sticky --mouse --on-top --escape-ok --button OK --hide-value | while read BrNew
do echo "$BrNew" > ${BrPath}brightness
done
|
Explanation of all options:
https://www.mankier.com/1/yad
Now i can remove heavy 'power manager' background services!
Tested on:
StretchDog
Xtahr
radky's Dpup Stretch 7.5 (RC3)
Porteus desktop 32-bit
Linux Mint 19 xfce`
To install:
- Confirm the simple echo command works on your machine. Try various values and see if your brightness changes. But not 0, your screen will go black! Start high-- my machines go up to 12000000+!
Code: | echo 10000000 > /sys/class/backlight/intel_backlight/brightness |
- Confirm yad works:
Code: | yad --scale --print-partial |
- save the script in a file called set-brightness
- if needed, edit the `BrPath=` line to match your backlight path.
- put the script into /usr/local/bin
- create a launcher on your panel or desktop, which runs the command set-brightness. Since it's in /usr/local/bin, your OS should find it-- no need to enter entire path.
Causes of failure:
- Your backlight path might not be intel. Figure out which backlight path is correct for your machine
Code: | ll /sys/class/backlight/ |
https://askubuntu.com/a/715310
https://askubuntu.com/questions/437983/how-to-find-backlight-is-managed-by-which-card
- You don't have backlight. But, as long as there's some command-line way to adjust the brightness of your screen, you can mod this script to use that command.
- You might have an old yad installed, or not installed at all. http://archive.ubuntu.com/ubuntu/pool/universe/y/yad/
- If you're not running as root, you may need to give your user (or all users) write-permissions on the brightness file
Code: | chmod 666 /sys/class/backlight/intel_backlight/brightness |
Funny story: i ran this on Mint 19 xfce. First time, Mint crashed Second time, Mint didn't crash, but you could see the slow-as-molasses performance, and jittery lags in the slider, compared with instantaneous responsiveness on xtahr, DebDog, or Porteus. Go Mint.
Volume slider
check out my alsa volume slider
http://murga-linux.com/puppy/viewtopic.php?t=114237
Description |
Shown running on the awesome StretchDog http://murga-linux.com/puppy/viewtopic.php?p=994600#994600 |
Filesize |
7.09 KB |
Viewed |
551 Time(s) |

|
Last edited by johnywhy on Sat 08 Sep 2018, 00:00; edited 33 times in total
|
Back to top
|
|
 |
Puppyt
Joined: 09 May 2008 Posts: 898 Location: Gatton, Queensland
|
Posted: Wed 05 Sep 2018, 08:18 Post subject:
|
|
I really like this, johnywhy! Confirming that your script works very nicely indeed in radky's Dpup Stretch 7.5 (RC3), OOTB.
Any chance of a red tint, perhaps to neatly sideline a similar function served by Redshift GUI and the like? Just thinking... but not seriously, Cheers
_________________ Search engines for Puppy
http://puppylinux.us/psearch.html; Google Custom Search; http://wellminded.net63.net/ others TBA...
|
Back to top
|
|
 |
johnywhy

Joined: 20 Aug 2011 Posts: 882
|
Posted: Wed 05 Sep 2018, 08:27 Post subject:
|
|
Puppyt wrote: | I really like this, johnywhy! Confirming that your script works very nicely indeed in radky's Dpup Stretch 7.5 (RC3), OOTB.
Any chance of a red tint, perhaps to neatly sideline a similar function served by Redshift GUI and the like? Just thinking... but not seriously, Cheers  |
Sweet!
i won't be doing a redshift tho, i don't like it myself :/
but yeah, i removed redshift cuz it's a ram hog.
THX
_________________ Now: X-Tahr 2.0! StretchDog! DevuanDog!
Tops: TarhNOP Vlina-R2 Racy
Used: Puppeee Precise Lucid Wary Tahrpup Quirky Slacko MacPup Saluki Puppy Studio LxPupTarh Lina-Lite Lina
i ♥ Puppy
Last edited by johnywhy on Wed 05 Sep 2018, 23:43; edited 1 time in total
|
Back to top
|
|
 |
Flash
Official Dog Handler

Joined: 04 May 2005 Posts: 13388 Location: Arizona USA
|
Posted: Wed 05 Sep 2018, 16:09 Post subject:
|
|
Tested in Dell Inspiron 15, model 5570, running Quirky Xerus64 8.6, with this error:
Code: | #Set-brightness
/usr/local/bin/Set-brightness: line 6: syntax error near unexpected token `('
/usr/local/bin/Set-brightness: line 6: `yad --scale --min-value $BrMin --max-value $BrMax --value $BrCur --print-partial --title 'Set brightnessradky's Dpup Stretch 7.5 (RC3)' --width 300 --fixed --sticky --mouse --on-top --escape-ok --button OK --hide-value | while read BrNew'
# |
|
Back to top
|
|
 |
johnywhy

Joined: 20 Aug 2011 Posts: 882
|
Posted: Wed 05 Sep 2018, 16:27 Post subject:
|
|
Flash wrote: | Tested in Dell Inspiron 15, model 5570, running Quirky Xerus64 8.6, with this error:
Code: | /usr/local/bin/Set-brightness: line 6: syntax error near unexpected token `(' |
|
sounds like your yad doesn't like parens in the title. Works with parens on my machine. Maybe your yad needs to be updated? I get:
Code: | # apt list yad
yad/testing,now 1:0.38.1 i386 [installed] |
If you have a chance, plz try without (RC3) your title. If that works, put the (RC3) back in, and surround the title with double-quotes instead of single-quotes.
THX!
_________________ Now: X-Tahr 2.0! StretchDog! DevuanDog!
Tops: TarhNOP Vlina-R2 Racy
Used: Puppeee Precise Lucid Wary Tahrpup Quirky Slacko MacPup Saluki Puppy Studio LxPupTarh Lina-Lite Lina
i ♥ Puppy
|
Back to top
|
|
 |
johnywhy

Joined: 20 Aug 2011 Posts: 882
|
Posted: Fri 07 Sep 2018, 22:07 Post subject:
|
|
new version posted. no buttons or titlebar.
cheers
_________________ Now: X-Tahr 2.0! StretchDog! DevuanDog!
Tops: TarhNOP Vlina-R2 Racy
Used: Puppeee Precise Lucid Wary Tahrpup Quirky Slacko MacPup Saluki Puppy Studio LxPupTarh Lina-Lite Lina
i ♥ Puppy
|
Back to top
|
|
 |
MochiMoppel

Joined: 26 Jan 2011 Posts: 1938 Location: Japan
|
Posted: Fri 07 Sep 2018, 23:03 Post subject:
|
|
@johnywhy: I understand why Flash receives an error and I don't understand why it works for you. Doesn't work for me either.
The single quotes don't match.
-title 'Set brightnessradky's Dpup Stretch 7.5 (RC3)'
The string breaks prematurely after brightnessradky. Either escape the apostrophe or make the title simpler
|
Back to top
|
|
 |
johnywhy

Joined: 20 Aug 2011 Posts: 882
|
Posted: Fri 07 Sep 2018, 23:37 Post subject:
|
|
MochiMoppel wrote: | @johnywhy: I understand why Flash receives an error and I don't understand why it works for you. Doesn't work for me either.
The single quotes don't match.
-title 'Set brightnessradky's Dpup Stretch 7.5 (RC3)'
The string breaks prematurely after brightnessradky. Either escape the apostrophe or make the title simpler |
embarrassed i didn't catch that
worked for me, cuz i didn't embed an apostrophe, i only tested parens
_________________ Now: X-Tahr 2.0! StretchDog! DevuanDog!
Tops: TarhNOP Vlina-R2 Racy
Used: Puppeee Precise Lucid Wary Tahrpup Quirky Slacko MacPup Saluki Puppy Studio LxPupTarh Lina-Lite Lina
i ♥ Puppy
|
Back to top
|
|
 |
johnywhy

Joined: 20 Aug 2011 Posts: 882
|
Posted: Fri 07 Sep 2018, 23:47 Post subject:
|
|
check out my new alsa volume slider
http://murga-linux.com/puppy/viewtopic.php?t=114237
_________________ Now: X-Tahr 2.0! StretchDog! DevuanDog!
Tops: TarhNOP Vlina-R2 Racy
Used: Puppeee Precise Lucid Wary Tahrpup Quirky Slacko MacPup Saluki Puppy Studio LxPupTarh Lina-Lite Lina
i ♥ Puppy
|
Back to top
|
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|