Brightness & colour temperature control for desktop PCs

Window managers, icon programs, widgets, etc.
Message
Author
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

Brightness & colour temperature control for desktop PCs

#1 Post by Mike Walsh »

Evening, all.

I had a gander at johnywhy's 'Simple brightness slider' a couple of days ago. It's a neat idea, and it's something I was tinkering with the idea of 2-3 years ago, before I knew much at all of how Puppy works.

I haven't yet tried it on the old Dell lappie. But it doesn't work at all on the big old Compaq desktop.

Simple reason being, that the directory Johny's based this around, /sys/class/backlight, although it exists on a desktop install.....there's nothing in there. The cupboard is bare, boys & girls!

-------------------------------------

I still wanted to find summat that would work for me, so I started searching the 'net.

Tried 'xbacklight'. Nope. Didn't do anything.

Tried 'xgamma'. Weeell.....it kinda worked. Sort of. It's supposed to work very much the same way as RedShift's brightness slider does - by manipulating the gamma 'ramp'. Except where RedShift makes a half-way decent job of things, this just makes everything look very odd..!

Then I tried another one, which is (to the best of my knowledge) built-in to all Linux distros; 'xrandr'. Aha....

----------------------------------------

I got this from a thread on askubuntu.com, where I started poking around after one of Johny's links sent me there.

https://askubuntu.com/questions/149054/ ... via-script

We're looking at the second reply here. Essentially, you run this command:-

Code: Select all

xrandr -q | grep " connected"
.....hit 'Enter', and, in the string that's returned, the very first item is the reference for your specific monitor.....the way Puppy is seeing it. In my case,

Code: Select all

VGA-0 connected 1024x768+0+0 (normal left inverted right x axis y axis) 304mm x 228mm
.....it's 'VGA-0', although in the answer itself, Ubuntu was seeing this guy's monitor as 'LVDS1'???

So; you take that first item. You insert it into the following command, like so (using my personal example):-

Code: Select all

xrandr --output VGA-0--brightness 0.5
.....where the number at the end represents the brightness value recognised by 'xrandr'. 0.0 is full dark; 1.0 is full bright. It'll recognise down to 0.01 steps.

To check whether this will work for you, we'll borrow a tip from johnywhy's thread. Open a terminal, enter:-

Code: Select all

yad --scale --print-partial
.....and hit the 'Enter' key.

You should get a wee YAD box appear with a slider in it. Click on the slider and move it back & forth, and, as you do so, you should see a series of readouts in the terminal, showing rising & falling values as you move the slider up & down. If you do, YAD's behaving itself, and performing as we want it to.....this is the slider's 'output', printed to the terminal.

Fred's given invaluable help with this, and added some stuff to the script which runs the first command, extracts that first item and inserts it into the second command, running that at the appropriate time. Thus, no need to figure out what your monitor is designated as, since the script 'detects' it automatically.

------------------------------------------------

I've put together a slider and tray icon for this. No MenuEntry; at startup, the tray icon is placed in the notification area, and you simply click it to bring the control up, and click 'Done' when finished. I was going to use the '--close-on-unfocus' option with this, where you can click anywhere on your desktop and it'll close, but it seems the ROX 'pinboard' is not recognised as a viable 'window', the way most DEs are.....so, 'Done' it is.


Image


The slider runs from the tray icon below; the black & yellow split circle:-


Image


You won't need an up-to-date version of YAD for this; it works fine even with the elderly version included in most Pups by default. Bottom line; with YAD's backward compatibility, whatever version you have on your system, it'll run.

The Brightness Control .pet is attached below. If needed, you can find 'generic' versions of YAD 0.40.0 @ my G-Drive, as detailed below.

The .pet itself is architecture-independent.

---------------------------------------------------

Thanks to Johny for the inspiration, and to Fred for his usual patient & helpful assistance. Here's hoping some of you may find this useful; after all...

.....why should laptops have all the fun?

Enjoy.


Mike. :wink:

Attachments:-

'Generic' .pets of the current YAD (v0.40.0) available from my G-Drive.

32-bit & 64-bit.

All .pets from this thread attached below.....including a redshift 'backend' package (supplied by Fred) for those older Pups where you just cannot obtain it through the Package Manager. Modern 32- and 64-bit Pups won't have this problem.
Attachments
redshift_cli-v1.7-i686.pet
32-bit redshift 'backend' package (for older Pups where you can't obtain it from the PPM)
(106.04 KiB) Downloaded 441 times
ScreenControl_redshift-v1.4-noarch.pet
Dual-slider ScreenControl utility, v1.4 - noarch (needs redshift command-line utility installed from PPM)
(24.89 KiB) Downloaded 482 times
ScreenControl-v1.3-amd64.pet
ScreenControl v1.3 - SCT-based 64-bit .pet
(28.83 KiB) Downloaded 502 times
ScreenControl-v1.3-i686.pet
ScreenControl v1.3 - SCT-based 32-bit .pet
(28.7 KiB) Downloaded 476 times
Brightness_control_4_desktop_PCs-v1.1.pet
Tray-based brightness slider for desktop PCs, utilising xrandr
(24.7 KiB) Downloaded 533 times
Last edited by Mike Walsh on Tue 18 Sep 2018, 23:56, edited 7 times in total.
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#2 Post by Mike Walsh »

Hm! A slight case of two apps apparently using the same set of commands here, kiddiwinks. 'Twould appear that I've inadvertently isolated the same command that RedShift must use for its own brightness control.....

(*Aw, shucks..! Hell & tarnation.....*)

Now then; let me state, here & now (to quash any confusion); this Brightness Control .pet works perfectly, as a standalone app.

Which is absolutely true. Let me explain.....

----------------------------------------------------

If (as I do) you use RedShiftGUI - to control screen hue late at night - and, moreover, have it set to auto-start - whether sym-linked into /root/Startup, or by some other means - it apparently interferes with the command in use by the Brightness Control .pet.

I put this thing together this afternoon, after Fred had answered a query or two about its operation on the YAD tips thread. It was working perfectly at that time.

Installing the .pet into another Pup this evening, it installed and worked exactly as it should do. Except for one small, trifling detail.....

It didn't actually do what it was supposed to!

(*sheesh*)

Anyway; I tried the same terminal command that makes this work in 3 or 4 other Pups. Exactly the same thing again. Then I booted back into Slacko 560, where I'd originally been putting this thing together, and where I've been for the last 2 or 3 days. Ah, hell.....wouldn't you just know it? Yep; no workee! Curious. Very curious, in fact (given that it worked perfectly earlier on..!)

Then, something occurred to me. Fred had mentioned to me earlier on that RedShiftGUI also has a 'true' brightness control. A-ha. I wonder.....

As an experiment, I turned RedShift off temporarily. Clicked on the tray icon for the Brightness Control, and.....wouldn't you just know it?

Working perfectly. So; RedShift was somehow interfering with the command in use by the Brightness Control.

RedShift also has a feature whereby if you right-click the tray icon, it 'disables' the normal cycle of getting redder as time goes by (I have mine set for a very slow transition, taking something like 2 hours to reach its final setting, OK?) To indicate this, the normally red tray icon turns blue.....and RedShift no longer does its thing until you right-click the icon again, turning it red again.

To check this, I brought RedShift's window up, and experimented with the Brightness Control, together with right-clicking RedShift's icon back & forth. And uncovered the mystery in the process..!

---------------------------------------------------------

In normal operation, RedShift's icon is red, and the window looks like this:-


Image


When it's like this, all the Brightness Control does is flicker when you move the slider.....but the screen remains at full brightness. When you right-click the tray icon, to 'disable' RedShift, this happens:-


Image


Notice the previously blank check-box for 'Disable auto-adjust'. It now has a tick in it.....and in this condition, the Brightness Control app's slider works, dimming or brightening the screen (as it's meant to).

Conclusion? When RedShift is in normal operation, after sunset its own internal coding is obviously disabling xrandr from performing this particular operation. So.....if you run RedShift, disable it by right-clicking the tray icon IF you want the Brightness Control to work. Bit pointless, I know, given that RedShift has its own brightness control that isn't affected by all this. Conversely, after sunrise (when it's quit doing its thing, and has 'turned off' for the daylight hours), this particular bit of coding has obviously been disabled for the duration by the geo-location stuff.

If, however, you don't run RedShift, there IS no problem!

Talk about 're-inventing the wheel', huh...? How's that for detective work? :lol: :lol:


Mike. :wink:
User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#3 Post by fredx181 »

Hi Mike,
Conclusion? When RedShift is in normal operation, after sunset its own internal coding is obviously disabling xrandr from performing this particular operation.
So... if I understand well, your brightness slider doesn't work when Redshiftgui is in "night mode" ?
For me it's not the case, brightness slider works well in that case, but... I'm on a laptop :)
But I do experience something else: when using the brightness slider, the "night" setting from Redshifgui is disabled (again to full "blueish")
Not a big problem though (all I have to do is go in the Redshifgui settings and adjust the night temperature slider a little and it goes back to how it was).
EDIT: But then brightness is set to 100% again, I set it earlier to 70%, oh well..

BTW: I found that redshift (commandline program) can do the same as xrandr, setting the brightness only.
Below only needs xrandr to set the initial brightness value, the actual brightness setting is done by redshift.

Code: Select all

XR=$(xrandr --verbose | grep -i brightness | cut -f2 -d ' ' | head -n1)
BrCur=`awk "BEGIN {print $XR*100}"` # calculate, so e.g. 0.5 gets 50
BrMax="100"
BrMin="10"
yad --undecorated --on-top --geometry=450x70-30-30 --text="                  SCREEN   BRIGHTNESS   CONTROL" --scale --value $BrCur --print-partial --min-value $BrMin --max-value $BrMax --button="Done":1 | while read BrNew; do
redshift -l 00.00:00.00 -o -b $(awk "BEGIN {print $BrNew/100}")
done
Perhaps this doesn't give the problems you described above.

Fred
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#4 Post by Mike Walsh »

Hi, Fred.

Umm; that doesn't work for me. Doesn't seem to do anything, actually.....not on my desktop, anyway. But I've got round it, by returning to Puppy 'first principles'; K.I.S.S.....what else?

I'm going to do away with RedShift throughout the kennels.....and use this instead:-

"SCT" - (Set Colour Temperature)

Labbe5 actually discovered this around a year ago, though he's just recently re-posted about it:-

http://www.murga-linux.com/puppy/viewtopic.php?t=111450

It's a wee binary, around 8-12k in size, that allows you to set colour temperature directly through the terminal, instead of relying on RedShift's complex geo-location stuff. And since I'm not too concerned about losing all the complex automation that goes with it.... I think I can click a button to change screen temperature if, as & when I need to!

RedShift's ( and, indirectly, f.Lux's) big selling point in all this is that it's all taken care of for you, and implemented totally automatically (without you needing to concern yourself about it). But it does add a big chunk of complexity to the process.

I normally have my lower limit in RedShift set to 3600.....that's a comfortable night screen 'temperature' for my eyes. I vaguely remember you had to compile the binary back then, but it's as simple as YAD to do; even simpler, I seem to recall.....there was an auto-compile script included. Now, it appears to be in the repos.

Anyway; I've got it in most of my Pups already. To implement, I simply enter

Code: Select all

sct 3600
.....in the terminal, and it sets it immediately.

So; I've put a tiny script together to be put in /usr/local/bin, named (appropriately) 'sct.sh'. Like so:-

Code: Select all

#!/bin/sh
#
# Launcher for sct ['Set Color Temperature']
#
sct 3600
Then, /usr/local/bin/EMBC.sh (the Brightness control YAD GUI) calls it via an additional button, like so:-

Code: Select all

#!/bin/bash
#
# Brightness control slider for desktop 'external' monitors - with inspiration from johnywhy, and many thanks to Fredx181
#
# detect monitor
MON=$(xrandr -q | grep " connected" | cut -f1 -d ' ')
# find current xrandr brightness value
XR=$(xrandr --verbose | grep -i brightness | cut -f2 -d ' ' | head -n1)
BrCur=`awk "BEGIN {print $XR*100}"` # calculate, so e.g. 0.5 gets 50
BrMax="100"
BrMin="10"
yad --undecorated --on-top --geometry=450x70-30-30 --text="                  SCREEN   BRIGHTNESS   AND   TINT   CONTROL" --scale --value $BrCur --print-partial --min-value $BrMin --max-value $BrMax --button="Night Tint":sct.sh --button="Done":1 | while read BrNew; do
# division using awk, so xrandr value gets e.g. 0.5 rather than 50
xrandr --output $MON --brightness $(awk "BEGIN {print $BrNew/100}")
done 

Image


If I want to use the slider, it auto-disables sct.....but when I have it dimmed, I don't want the red tint on anyway. When I'm finished, I just hit the 'Night Tint' button.....and colour temperature is restored at full brightness, regardless of slider position. Next time you open the Brightness control, the slider is back at 100.

Neat, & simple. To change the value to one that's comfortable for your own eyes, experiment with sct in the terminal, then edit /usr/local/bin/sct.sh to suit.

UPDATED VERSION (below):- The 'Night' button sets it immediately. The 'Day' button returns you to the standard 6500 daytime setting.

Well, it works for me.... (*shrug*) :)

------------------------------------------
EDIT:- Added a second small sct script & added another button (for the 'daytime' setting - see above); added 'Info' button to explain 'sct' usage; compiled the 64-bit version of sct, and made up .pet packages for both 32- and 64-bit Pups.....with the sct binary included in the package.


Image


Pets attached below.


Mike. :wink:
Attachments
Brightness_and_tint_4_desktop_PCs-v1.2-i686.pet
Tray-based bright/tint control - 32-bit
(29.15 KiB) Downloaded 436 times
Brightness_and_tint_4_desktop_PCs-v1.2-amd64.pet
Tray-based bright/tint control - 64-bit
(29.34 KiB) Downloaded 436 times
User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#5 Post by fredx181 »

Mike Walsh wrote:Umm; that doesn't work for me. Doesn't seem to do anything, actually.....not on my desktop, anyway.
Could be because you don't have redshift installed maybe ? (not to confuse with redshiftgui, redshift is a command line program)
But... nevermind... you made it very nice now with the "Night" and "Day" buttons :)
Didn't know about sct, btw, nice !

Fred
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#6 Post by Mike Walsh »

Hi, Fred.

Well, sct is very lightweight (back to Puppy 'first principles', like I said), and, TBH, I'm not so interested in the transition period as I am the end values; the day-time setting, and the night-time setting. It's a good find by labbe5.

Sct pretty much achieves the same end result as RedShift, it's just manual, rather than automatic. So you can get away with 2 buttons, one for each of the two values.

And, er, BTW; I think you're probably right about RedShift not being installed at the time when I tried that script modification. I was in the middle of uninstalling/changing-over from one to t'other last night, across the whole kennels.......I couldn't honestly tell you which Pup I was in, nor what the state of play was at the point when I tried the new script. 'Twas a real case of the left-hand not being at all sure quite what the right-hand was getting up to, at one stage.

Even I was getting confused..! :lol:


Mike. :wink:
User avatar
Moat
Posts: 955
Joined: Tue 16 Jul 2013, 06:04
Location: Mid-mitten

#7 Post by Moat »

This is neat Mike - I feel every desktop environment should include both a GUI brightness and tint control. This seems an excellent candidate for WoofCE inclusion... very lightweight!

Quick question/idea (go ahead and ignore if ya' desire); Why not simply a slider for both? It wouldn't require modifying a text entry for sct, and as an example I own a particular Dell laptop with an awfully "cold"/blue-ish LED-backlit display that can be hit-or-miss when zeroing in on sct/color temp to make it presentable (set a temp, browse/play with apps, still too cold/warm, set again, browse some more, repeat, etc...) - having an already-open, background GUI slider to tweak on the fly would seem to be perfect for that sort of fine-tuning.

(edit to add); I suppose one could even add an "SCT Save" button to save the current tint setting, and then toggle that "nightime" setting on/off with a "Day/Night" button... :?:

Just a passing thought(s)! :oops:

BTW, I've ran across another "modern-but-pleasant" free font today that I'm really enjoying - Lato - thought you might like to give it a peek, too, if you haven't already;

http://www.latofonts.com/lato-free-fonts/

Bob
User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#8 Post by fredx181 »

Moat wrote:This is neat Mike - I feel every desktop environment should include both a GUI brightness and tint control. This seems an excellent candidate for WoofCE inclusion... very lightweight!

Quick question/idea (go ahead and ignore if ya' desire); Why not simply a slider for both? It wouldn't require modifying a text entry for sct, and as an example I own a particular Dell laptop with an awfully "cold"/blue-ish LED-backlit display that can be hit-or-miss when zeroing in on sct/color temp to make it presentable (set a temp, browse/play with apps, still too cold/warm, set again, browse some more, repeat, etc...) - having an already-open, background GUI slider to tweak on the fly would seem to be perfect for that sort of fine-tuning.

(edit to add); I suppose one could even add an "SCT Save" button to save the current tint setting, and then toggle that "nightime" setting on/off with a "Day/Night" button... :?:

Just a passing thought(s)! :oops:

BTW, I've ran across another "modern-but-pleasant" free font today that I'm really enjoying - Lato - thought you might like to give it a peek, too, if you haven't already;

http://www.latofonts.com/lato-free-fonts/

Bob
No idea yet how to combine two sliders for brightness and night-time color, anyway here's what I experimented with slider for changing sct temperature value:

Code: Select all

[ -f /tmp/sct_value ] && SctCur=$(cat /tmp/sct_value) || SctCur=6500
SctMax="6500"
SctMin="2400"
yad --undecorated --on-top --geometry=450x70-30-30 --text="\t\t\t\t\tRedshift Control" --scale --value $SctCur --print-partial --min-value $SctMin --max-value $SctMax --button="Done":1 | while read SctNew; do
sct $SctNew
echo $SctNew > /tmp/sct_value
done
Fred
User avatar
rg66
Posts: 1158
Joined: Mon 23 Jul 2012, 05:53
Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!

#9 Post by rg66 »

fredx181 wrote:No idea yet how to combine two sliders for brightness and night-time color

Code: Select all

yad --form --field="Brightness:scl" --field="Night Color:scl"
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
User avatar
bigpup
Posts: 13886
Joined: Sun 11 Oct 2009, 18:15
Location: S.C. USA

#10 Post by bigpup »

Mike Walsh,

Keep tweaking.
You are going to make something that should be a core feature of any Puppy version.

On a desktop.
I just wonder how often it is going to be needed.
I always set the monitor, using the monitors internal controls. One time setup, and never do it again.
It is in the same place, same room, same lighting, all the time.

Now a laptop.
Those things constantly need to adjust the screen brightness and color temp.

Thanks for working on this!!
The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected :shock:
YaPI(any iso installer)
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#11 Post by MochiMoppel »

@Mike @Fred: Before you move into fancy stuff like tint control here some thoughts about the initial brightness pet:

- The comment in the script reads "Brightness control slider for desktop 'external' monitors". Whatever this is supposed to mean it does not work if the external monitor is attached to a laptop.
In such case 2 monitors are connected but the script takes only the current value of whatever monitor is first in the list and as soon as the slider is moved xrandr produces an error as it can't accept a new value for 2 monitors at the same time. You end up with a nice slider that does nothing.

- As already mentioned Yad is not installed in all Puppies. The newest Yad is even less common. That brings up the question: Is Yad the right tool or wouldn't gtkdialog be the better choice. Apart from the guaranteed availability in all Puppies something like "--close-on-unfocus" is standard in gtkdialog and the a clunky pipe to "while read BrNew; do" would also be unnecessary. And yes, it would allow 2 or more sliders in the same dialog.
User avatar
Moat
Posts: 955
Joined: Tue 16 Jul 2013, 06:04
Location: Mid-mitten

#12 Post by Moat »

fredx181 wrote:... here's what I experimented with slider for changing sct temperature value:
Works!! :) (although, admittedly, on ETP's Cinnamon remix of your Bionic Dog...)

And also confirming what both of you guys have already found; that adjusting either one on it's own - brightness or tint - automatically negates the other one's previous setting. My half-hearted guess is that both are adjusting the same gamma arguments; brightness = all three colors (red, green, blue) go up and down together, while sct likely targets only green and blue - leaving red to 'shine through' as the dominant, warming color at lower K settings. And touching either initially reverts all three colors to 100%, I'm thinkin' (sure looks that way...).

So it appears as (probably!) only one is useable at a time - either brightness OR tint. An alternative approach that comes to mind would be a brightness control that actually targets the hardware, itself - as in the fn/brightness keys, or tray applets as available in DE's other than JWM. For instance, I just tried that on an Ubuntu Mate install, using Mate's tray brightness slider and Fred's tint slider script - and indeed then, both work - each retaining their respective adjustments. But another half-hearted guess would be that such might entail a considerably greater amount of code (i.e.; detecting the target computer's brightness hardware controller?), and might be beyond what Mike may wish to dig himself into. :lol:

All good, though - great on ya', Mike, for pursuing this little useful utility/idea!! 8) Certainly well beyond my pay scale... :oops:

Bob
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#13 Post by Mike Walsh »

Goodness, gracious me. I had no idea something like this would provoke such debate.....

Before I go any further, I want to re-state heartfelt thanks to two individuals:-

johnywhy - for giving me the idea in the first place.

fredx181 - without whose sterling work none of this, so far, would have been possible.

Once again, I refuse to take credit for other people's work. I'm happy to incorporate it into something in which I've attempted to utilise that effort.....but the credit will always be very clearly stated.

Let me try and respond to various commenters:-

------------------------------------------------------

@ moat:- Glad you like the concept, Bob. It came about through finding out that johnywhy's script wouldn't work for me.....because on my desktop, at least, /syc/class/backlight was empty (and thus nowt to work with!)

Which is why I started digging around for alternatives, as detailed above. The eventual candidates were either already in Puppy, or were so small as to make no difference; I remember you being very enthusiastic about sct when labbe5 first discovered it a while back.

Like you, I, too, feel that something like this is an essential tool for incorporating into Puppy. Although I like RedShiftGUI, I do feel that all that geo-location stuff is not, strictly speaking, really necessary. I'm quite capable of making the adjustment manually when I want to. And, yes, you're quite right; the two do effectively cancel each other out. Which suits me, personally; when I have the screen dimmed, I don't want it 'tinted'. Conversely, when I have the 'red-shift' effect enabled at night, I find I don't need it dimmed as well.

As for your observations about adding the ability to directly address the hardware so that both can work at the same time? Bob, if we do that, it will add further coding.....and no, 'it's not a route I want to pursue. The whole intention of adding sct into the mix was as a lightweight, 'manual' replacement for RedShiftGUI. I have no intention of bloating it up the size of RedShiftGUI; if we do that, I might just as well stick with it, and give up on this wee project altogether!

-----------------------------------------------------

@ MochiMoppel:- I know you've always been a proponent of keeping Puppy (and its code) as small and lightweight as possible.....and of making use of what's already there by default.

I find I'm starting to see the merit in such a policy. Xrandr is already there. Sct, though it isn't, is so small as to be negligible. Okay, yad is a bit bigger, it's true.....but I still don't feel that 180k or so is 'out-of-the-way'. I have experience with yad already. With gtk-dialog, I would be starting from scratch again.....and my personal situation is not such that it permits me endless hours in front of this thing.

Moreover, despite compiling supposedly being kernel-specific, I've found with both yad and sct that it doesn't matter what Puppy they've been compiled in.....they will work across a broad range of Pups of that particular architecture. Maybe not 'optimized' to perfection (and thus not really the 'done' thing), but well enough to be fully functional.

I understand where you're coming from when you deplore those of us who insist on adding GUIs to apps that are essentially command-line in nature. It's more 'bloat', isn't it? The sole reason I have for doing this with various items is that I'm thinking of the 'newbies' and Windoze 'refugees'; I can sympathize with 'em, 'cos I was in their shoes as little as 5 years ago. They're coming from a GUI-centric eco-system, where console work is very much the exception as opposed to the rule.

And it's also why I firmly believe in making as big a choice of apps, etc., available to Puppians as possible.....even if it does duplicate existing items.

I confess, I hadn't considered the scenario of folks connecting external monitors to laptops. It's not something I've ever seen myself doing.....but in that case, johnywhy's brightness control probably would work better, as it makes use of existing laptop 'stuff'. The scenario for this is a monitor as a standard component of an existing desktop tower set-up.

-------------------------------------------------------------------

@ bigpup:- I'm playing around with this. My own case is that my eyeballs were permanently weakened following several years working in the mineral-processing industry. I just cannot handle bright light.....and that's all there is to it.

We'll see how it progresses.

-------------------------------------------------------------------

@ rg66:- RG, thanks for that! I see what's been implemented.....making the scale an 'element' of a field. That hadn't occurred to me.....and I haven't come across mention of that particular trick in the man pages anywhere.

I shall experiment.....and see what I can do with it.


One fact is absolutely inescapable.....and is as true today as it's always been. No matter what any of us 'packagers' do, we 'cannae please all the folk, all of the time'. There will always be someone finding fault with what you do, convinced there's a better (different? alternative?) way that something-or-other should have been done. In that light, it's not hard to see how Redmond's products end up being as bloated as they are; they're attempting to be 'all things to all men'.....and building every last possible bit of a vast choice of different ways of doing the same thing into the base OS itself.

In some ways, they're merely reaping the fruits of all those years of plotting & conniving to ensure Windows was the dominant OS; it's given them a much larger user-base to have to satisfy and keep happy!


Mike. :wink:
User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#14 Post by fredx181 »

Another study: :) EDIT: Mike, just see your post, further discussing and tweaking can also be in another thread if you want. :wink:

Code: Select all

#!/bin/bash
#

color_ctrl () {
[ -z "$(cat /tmp/BR_value 2> /dev/null)" ] && echo 100 > /tmp/BR_value
# export BR_VALUE=$(cat /tmp/BR_value 2> /dev/null)
[ "$(cat /tmp/clr_temp 2> /dev/null)" ] && TCur=$(cat /tmp/clr_temp 2> /dev/null) || TCur=6500
TMax="8000"
TMin="2000"
yad --undecorated --on-top --geometry=450x70-30-150 --text="\t\tRedshift Temperature Setting" --scale --value $TCur --print-partial --min-value $TMin --max-value $TMax --button="Done":1 | while read TNew; do
echo $TNew > /tmp/clr_temp
redshift -l : -O $TNew -b $(awk "BEGIN {print $(cat /tmp/BR_value 2> /dev/null)/100}") 1>/dev/null
done
}
export -f color_ctrl

[ -z "$(cat /tmp/clr_temp 2> /dev/null)" ] && echo 6500 > /tmp/clr_temp
[ "$(cat /tmp/BR_value 2> /dev/null)" ] && BrCur=$(cat /tmp/BR_value 2> /dev/null) || BrCur=100
BrMax="100"
BrMin="10"
yad --undecorated --on-top --geometry=450x70-30-30 --text="                  SCREEN   BRIGHTNESS   CONTROL" --scale --value $BrCur --print-partial --min-value $BrMin --max-value $BrMax --button="Tint":'bash -c color_ctrl' --button="Done":1 | while read BrNew; do
echo $BrNew > /tmp/BR_value
redshift -l : -O $(cat /tmp/clr_temp) -b $(awk "BEGIN {print $BrNew/100}") 1>/dev/null
done 
This is just using redshift, so it's required to have it installed, not redshiftgui.

Clicking the 'Tint' button shows another slider for setting the temperature.
My goal was that both sliders operate independently, so not -for example- if you adjust the brightness that the value for the tint get reset or vice versa.
rg66 wrote:fredx181 wrote:
No idea yet how to combine two sliders for brightness and night-time color

Code:
yad --form --field="Brightness:scl" --field="Night Color:scl"
Yes, but you cannot "preview" that way AFAIK.
MochiMoppel wrote:- The comment in the script reads "Brightness control slider for desktop 'external' monitors". Whatever this is supposed to mean it does not work if the external monitor is attached to a laptop.
In such case 2 monitors are connected but the script takes only the current value of whatever monitor is first in the list and as soon as the slider is moved xrandr produces an error as it can't accept a new value for 2 monitors at the same time. You end up with a nice slider that does nothing.
Perhaps the above script solves that problem (doesn't use xrandr), I cannot test atm.

Fred
Attachments
2018-09-16-151816_504x284_scrot.png
(127.13 KiB) Downloaded 1044 times
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#15 Post by MochiMoppel »

Mike Walsh wrote:Xrandr is already there. Sct, though it isn't, is so small as to be negligible. Okay, yad is a bit bigger, it's true.....but I still don't feel that 180k or so is 'out-of-the-way'.
Size is not an issue but availability is. At least for me.
I understand where you're coming from when you deplore those of us who insist on adding GUIs to apps that are essentially command-line in nature. It's more 'bloat', isn't it?
It's not more bloat and I never deplored anything. I have no idea what you are referring to
I confess, I hadn't considered the scenario of folks connecting external monitors to laptops. It's not something I've ever seen myself doing.
A very common scenario in our company and even for me at home. I seldom use my tower anymore since a laptop is so much quieter. Nevertheless I can't work with a tiny laptop screen and need a big external monitor. And people who do use a tower might use them with 2 monitors :wink:

Yad is fine if you are comfortable with it. The script is your baby and can do the job. My only intention was to give feedback and let you know that it fails in a scenario like mine. I leave it to you to fix or ignore it.
fredx181 wrote:Perhaps the above script solves that problem (doesn't use xrandr), I cannot test atm.
xrandr wouldn't be a problem.
User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#16 Post by fredx181 »

MochiMoppel wrote:fredx181 wrote:
Perhaps the above script solves that problem (doesn't use xrandr), I cannot test atm.
-------------
xrandr wouldn't be a problem.
I understood that the problem was because xrandr detects only one monitor in Mike's script.
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#17 Post by Mike Walsh »

@ MochiMoppel:-

Feedback is appreciated, certainly. Fred's newest script (utilising redshift) probably does get round this.....but I wanted to get away from RedShift.

--------------------------------

@ fredx181:-

Either you're a mind-reader, mate.....or I am! I've only just found your last but one post; I've been working on a way to implement the SCT slider control you got running (which works fine, BTW.)

I initially thought of making the tray icon call a 'Function Selector', where you decided which 'utility' you wanted (bright or tint), and it then called up each control independently. And then I thought I might just as well call the SCT slider up from the brightness control.....in the same way as the preset buttons.


Image


...and then:-


Image


.....only i set mine on a staggered 'overlap', rather than one above the other.

And that, I feel, is probably about as far as I really intend to take it. It probably won't suit the more finicky amongst us (like Bob! :) ), who would prefer absolutely everything to work just so. I really don't want to be digging around at the hardware level; this was fully intended to be just a simple, straight-forward control. As previously stated, I wanted to get away from RedShift ( in any guise), and go as 'basic' as it's possible to get while still retaining essential functionality. Which is why I like sct; tiny, yet functional.....in the best 'Puppy' tradition.

But I have to wonder; just where do you 'draw the line' when you're doing this kinda stuff? At what point do you say, 'That's it; enough is enough. It's a done job...'? I'm happy with feedback, sure; it does nothing but help. But as I said, you cannae please everybody.....

(*shrug*)

Pets for the latest (and probably last) 'incarnation' can be found attached to the original post on page 1.....and links for current versions of YAD (0.40.0) - if required - are there also.
Mike. :wink:
Last edited by Mike Walsh on Sun 16 Sep 2018, 23:01, edited 1 time in total.
User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#18 Post by fredx181 »

Hi Mike,
But I have to wonder; just where do you 'draw the line' when you're doing this kinda stuff? At what point do you say, 'That's it; enough is enough. It's a done job...'? I'm happy with feedback, sure; it does nothing but help. But as I said, you cannae please everybody.....

(*shrug*)

Pets for the latest (and probably last) 'incarnation' can be found attached below.....
Here we seem to disagree with each other (if you don't mind :)).

Why not work (together or alone) on something until it's usable for most people ?
That's where sharing is for, that it's not for your own use only.
Just a few days of testing and experimenting is usually not enough to make a good program.
MochiMoppel has a point, just like you had a point when you found that johnywhy's script didn't work for you.

Two things I'd like to see as improvement:
- That it works with most computers.
- That the brightness and temperature sliders don't "reset" each other.
The last, I found, is possible with redshift commandline program, because it can do both.
(with some tweaking, setting just brightness and temperature separate, not resetting each other)
Anything wrong with redshift ? It's maybe a bit bigger than stc, but still small.
(again, to avoid confusion, not talking about redshiftgui)

.... sofar the rant.... excuse me...

Here's another study (again by using redshift), btw, has the two sliders in one dialog:
(not conflicting with each other for me)

Code: Select all

#!/bin/bash

fkey=$(($RANDOM * $$))

[ -z "$(cat /tmp/clr_temp 2> /dev/null)" ] && echo 6500 > /tmp/clr_temp
[ -z "$(cat /tmp/BR_value 2> /dev/null)" ] && echo 100 > /tmp/BR_value
# export BR_VALUE=$(cat /tmp/BR_value 2> /dev/null)
[ "$(cat /tmp/clr_temp 2> /dev/null)" ] && TCur=$(cat /tmp/clr_temp 2> /dev/null) || TCur=6500
TMax="8000"
TMin="2000"
yad --plug="$fkey" --tabnum=1 --undecorated --on-top --text="\t\tRedshift   Temperature   Setting" --scale --value $TCur --print-partial --min-value $TMin --max-value $TMax --button="Done":1 | while read TNew; do
echo $TNew > /tmp/clr_temp
redshift -l : -O $TNew -b $(awk "BEGIN {print $(cat /tmp/BR_value 2> /dev/null)/100}") 1>/dev/null
done &

[ "$(cat /tmp/BR_value 2> /dev/null)" ] && BrCur=$(cat /tmp/BR_value 2> /dev/null) || BrCur=100
BrMax="100"
BrMin="10"
yad --plug="$fkey" --tabnum=2  --undecorated --on-top --text="                  Screen   Brightness   Control" --scale --value $BrCur --print-partial --min-value $BrMin --max-value $BrMax --button="Tint":'bash -c color_ctrl' --button="Done":1 | while read BrNew; do
echo $BrNew > /tmp/BR_value
redshift -l : -O $(cat /tmp/clr_temp) -b $(awk "BEGIN {print $BrNew/100}") 1>/dev/null
done &

yad --center --paned --key="$fkey" --undecorated  --button="gtk-quit:1" --buttons-layout=center --geometry=450x70-30-30 --orient=vert
This requires higher yad version, not sure which, I think from 0.35 on, as it uses the --paned option.

EDIT: Made some small changes in the code above.
One thing may be better: To replace /tmp with some path that will be preserved after reboot (for the files that keep the values), but not sure yet.
EDIT2: To explain: this part of redshift command:

Code: Select all

redshift -l : 
may look a bit strange.
It's just empty value for "latitude:longitude".
Without specifying the "-l" value, redshift will complain, so empty values is the workaround.

Fred
Attachments
2018-09-16-180529_503x226_scrot.png
(98.43 KiB) Downloaded 432 times
Last edited by fredx181 on Sun 16 Sep 2018, 17:44, edited 1 time in total.
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#19 Post by Mike Walsh »

Hi, Fred.

Oh, it's not that I've got anything against Redshift..! I was just trying to go as small as possible, that was all. But you're right, of course; a version that works for as many people as possible would definitely be best.

Where d'you get your redshift from? Repos.....or from Jon Lund Steffenson's site?

I was doing some experimenting with rg66's twin-slider option, but I couldn't figure out how to get the function stuff working with it at all, since I found that if you don't have both fields in the same line, you only get the first one showing.....even when 'escaping' between them.

I've still got a lot to learn, y'know!

I'll give this latest version a whirl. I'm in Xenial64 ATM; I installed Redshift through the repos, so you get the commandline version anyway.

(Hm. Only 55k. Not as big as I thought.)

Well, now. Let's see what happens, shall we?.....


Mike. :wink:
User avatar
Moat
Posts: 955
Joined: Tue 16 Jul 2013, 06:04
Location: Mid-mitten

#20 Post by Moat »

Mike Walsh wrote: It probably won't suit the more finicky amongst us (like Bob! :) )...
:lol: :lol: Eh, like I mentioned - ignore me!! :lol: I've got nothing better to do this weekend than pester, and just thought my pestering could maybe, possibly add a little something to the otherwise constructive dialog. But yep - I totally agree with you on the simplicity/size of SCT, and the (me too, personally) lack of need for all of the background Redshift auto-adjust fluff. Appears to boil down to limitations inherent in each application in regards to this particular goal (Redshift = unnecessary bloat, SCT = lack of brightness/tint control separation). All a compromise, I guess - no matter how ya' slice it, eh? :)

I need to boot up a Pup here, and try your latest .pets - looks like an excellent all-around, super-lightweight solution...!! 8)

Bob
Post Reply