Author Topic: Controlling brightness from other WMs  (Read 4049 times)

DonOregano

  • Newbie
  • *
  • Posts: 24
    • View Profile
Controlling brightness from other WMs
« on: July 07, 2018, 03:59:21 pm »
I'm trying to configure i3 to run on my Gemini, which may seem like a very strange thing to do, but I think that a keyboard-centric environment may turn out to be a really nice thing for the Gemini. Anyway, I am having trouble with the brightmess controls, and I'm wondering if anyone has any tips for me.

I have tried running the brightness control scripts that LxQt uses, but nothing happens. Looking a little bit deeper into them, I realize that they send dbus commands to the repowerd daemon. And looking at the logs:

Quote
repowerd[683]: g_dbus_connection_call_sync_internal: assertion 'object_path != NULL && g_variant_is_object_path (object_path)' failed
repowerd[683]: LogindSessionTracker: dbus_get_session_uid() failed to get session uid:

Sooo, something is going on with a logind uid?

I tried looking at the logs that repowerd spits out when i log into LxQt vs i3, and it appears that when I log into LxQt a lot of stuff happens, like logind/seat/dbus stuff. But when I log into i3, nothing. However, if I log in to LxQt and log out and into i3 without a reboot I get working brightness controls.

What is the magic that LxQt does, and how do i replicate it?

Eric BF

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Controlling brightness from other WMs
« Reply #1 on: July 08, 2018, 08:54:51 am »
Quote from: DonOregano
I'm trying to configure i3 to run on my Gemini, which may seem like a very strange thing to do, but I think that a keyboard-centric environment may turn out to be a really nice thing for the Gemini.
[...]
What is the magic that LxQt does, and how do i replicate it?
Not a strange thing to do at all!  I'm running stumpwm on mine.  Makes full use of the screen with nothing wasted and having a keyboard is perfect for this wm.

In any case, I have the same problem as you.  I've not figured out how lxqt does it.  What I have figured out is that you can adjust the brightness manually by changing the value in /sys/class/leds/lcd-backlight/brightness.  The value should be an integer in the range 1-255.  I am writing a shell script to do this but it needs root access.  I'm getting around this by using sudo within the script and having my account set up so that it does need a password to invoke sudo.
Gemini 4G Debian
OpenPandora with Debian

Da_Blitz

  • Hero Member
  • *****
  • Posts: 1579
    • View Profile
    • http://www.pocketnix.org
Controlling brightness from other WMs
« Reply #2 on: July 09, 2018, 03:02:00 am »
Quote from: Eric BF
Quote from: DonOregano
I'm trying to configure i3 to run on my Gemini, which may seem like a very strange thing to do, but I think that a keyboard-centric environment may turn out to be a really nice thing for the Gemini.
[...]
What is the magic that LxQt does, and how do i replicate it?
Not a strange thing to do at all!  I'm running stumpwm on mine.  Makes full use of the screen with nothing wasted and having a keyboard is perfect for this wm.

In any case, I have the same problem as you.  I've not figured out how lxqt does it.  What I have figured out is that you can adjust the brightness manually by changing the value in /sys/class/leds/lcd-backlight/brightness.  The value should be an integer in the range 1-255.  I am writing a shell script to do this but it needs root access.  I'm getting around this by using sudo within the script and having my account set up so that it does need a password to invoke sudo.

One thing i do at my end is use the command 'id' to see if the script is being run as root and if not rexec the script via sudo meaning i do not have to worry about which comamnds need to be runa s root and which do not there are also some more subtle security issues this can fix but they are more of a concern for the environment i was working in with hostile users with high skll levels

the trick i use on my own systems is to use tmpfiled from systemd to change the group owner of the brightness file to that of the 'input' user that is avialbie on most modern distros and already have my user added to that group allowing myself access without root privileges

i stole the chromebook backlight animations and converted them to a cli script at http://blitz.works/text11/file/b405360ab31...11/backlight.py may need some work to update paths to point ot the LED backlight but if there is a brightness file that is autodetected i would recommend using that one rather than the LED one
Personal Blog
Code
Twitter

Gemini Order: #95 (roughly)
Current Device: Samsung Chromebook Gen 3
Current Arm Devices Count: ~30
Looking to acquire: Cavium Thunder X2 Hardware

Eric BF

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Controlling brightness from other WMs
« Reply #3 on: July 09, 2018, 06:50:27 am »
Quote from: Da_Blitz
the trick i use on my own systems is to use tmpfiled from systemd to change the group owner of the brightness file to that of the 'input' user that is avialbie on most modern distros and already have my user added to that group allowing myself access without root privileges
Useful trick!  Thanks.
Gemini 4G Debian
OpenPandora with Debian

DonOregano

  • Newbie
  • *
  • Posts: 24
    • View Profile
Controlling brightness from other WMs
« Reply #4 on: July 11, 2018, 09:58:07 am »
Quote from: Da_Blitz
the trick i use on my own systems is to use tmpfiled from systemd to change the group owner of the brightness file to that of the 'input' user that is avialbie on most modern distros and already have my user added to that group allowing myself access without root privileges

Hmm, I can't get that to work. I created a file /etc/tmpfiles.d/backlight.conf, containing
Code: [Select]
#Type Path        Mode UID  GID  Age Argument
z     /sys/devices/platform/leds-mt65xx/leds/lcd-backlight/brightness   0666 - - - -

But it does not appear to have any effect. Help?

frnzndr

  • Newbie
  • *
  • Posts: 13
    • View Profile
Controlling brightness from other WMs
« Reply #5 on: August 30, 2018, 04:18:35 pm »
Has anyone figured out a solution for getting the relevant start scripts from lxqt working on i3, in particular for things like brightness control? If there was a solution above, I did not understand how it would work - was the idea that the linked script

I also have noticed the issue that at least on the default settings, the fonts are not rendered at all on the i3bar/i3status. Just asking as this question mentiones i3 specifically and I'd love to use it too, alternatively I can open a new thread for this.

Eric BF

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Controlling brightness from other WMs
« Reply #6 on: September 29, 2018, 06:11:09 am »
Quote from: frnzndr
Has anyone figured out a solution for getting the relevant start scripts from lxqt working on i3, in particular for things like brightness control?
I use stumpwm and simply wrote my own scripts. You can control the brightness directly by putting a value (<256) in /sys/class/leds/lcd-backlight/brightness. I bind the script to a particular key of my choosing.
Gemini 4G Debian
OpenPandora with Debian

frnzndr

  • Newbie
  • *
  • Posts: 13
    • View Profile
Controlling brightness from other WMs
« Reply #7 on: October 28, 2018, 05:07:01 pm »
Finally got back to looking into this, it seems that i3 is not able to evaluate the XF86MonBrightnessUp/Down key events for some reason. I've established with xev that the keypress events are properly generated on pressing Fn+b and Fn+n, but I cannot use that to trigger an event (such as calling a script to change brightness).
The same issue probably applies to the XF86AudioLowerVolume and XF86AudioRaiseVolume buttons.
Has anyone had similar issues, or a pointer for some solution? It's quite annoying to not be able to use those keycombinations. Could it be that the version of i3 supplied via Debian stretch is simply too old?
How does the standard window manager use them?

Eric BF

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Controlling brightness from other WMs
« Reply #8 on: October 29, 2018, 03:19:31 am »
Quote from: frnzndr
Has anyone had similar issues, or a pointer for some solution? It's quite annoying to not be able to use those keycombinations. Could it be that the version of i3 supplied via Debian stretch is simply too old?
How does the standard window manager use them?
stumpwm has the same problem.  All keys generated using the Fn key are not understood by the window manager itself (even keys like : and ;, surprisingly).  Something to do with the underlying X libraries used by these window managers.  I am not sure why the default window manager is able to process these keys.

However, note that the actual key codes are transmitted to applications. As I "live" in Emacs, it was simply a matter of binding the key to specific code, e.g.:
Code: [Select]
(global-set-key [XF86MonBrightnessDown] #'(lambda () (interactive) (shell-command "sudo /.../gemini.backlight.sh down")))
Gemini 4G Debian
OpenPandora with Debian

Adam Boardman

  • Full Member
  • ***
  • Posts: 191
    • View Profile
Controlling brightness from other WMs
« Reply #9 on: October 29, 2018, 06:36:48 am »
Quote from: frnzndr
Could it be that the version of i3 supplied via Debian stretch is simply too old?
I'd suggest that as unlikely, the whole linuxy key grabbing stuff is all based upon grabbing named keys as whole keys. Cite for example original LXQT and current KDE's/Gnome key grabbers eat 'r' keys as 'Print' on the UK keyboard, so you just have to disable the short-cut's or fix the code.

Quote from: frnzndr
How does the standard window manager use them?
Had be fixed with some changes to make it work with keys that do both letters and 'named functions', from commit messages:
https://github.com/gemian/lxqt-globalkeys/c...4b3c775ed18631f
and:
https://github.com/gemian/lxqt-globalkeys/c...d9b26447a1baa34

But its a while ago that I made those changes not certain that there aren't other tweaks in the other commits that might also be important.

Eric BF

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Controlling brightness from other WMs
« Reply #10 on: October 31, 2018, 02:55:12 am »
Quote from: Adam Boardman
I'd suggest that as unlikely, the whole linuxy key grabbing stuff is all based upon grabbing named keys as whole keys. Cite for example original LXQT and current KDE's/Gnome key grabbers eat 'r' keys as 'Print' on the UK keyboard, so you just have to disable the short-cut's or fix the code.

You can add ratpoison to that list. That was my first port-of-call in terms of tiling window manager for the gemini but it's unusable due to the r key (and some others, from memory) getting swallowed up. I thought I was going crazy... It's strange that some window managers work out of the box (i.e. stumpwm in my case).
Gemini 4G Debian
OpenPandora with Debian