Recent

Author Topic: LedKey - Switching the keyboard backlight  (Read 2861 times)

Guva

  • Jr. Member
  • **
  • Posts: 82
LedKey - Switching the keyboard backlight
« on: September 03, 2018, 08:50:25 pm »
Hello.
I wrote a small program to toggle the keyboard backlight linux.
https://github.com/GuvaCode/LedKey

prepared packages for Ubuntu 18.04/Linux Mint 19
https://github.com/GuvaCode/LedKey/releases

Tested only on Linux Mint 19.

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
Re: LedKey - Switching the keyboard backlight
« Reply #1 on: September 03, 2018, 09:05:44 pm »
Not very rich program. Core is
Code: Pascal  [Select][+][-]
  1. // Set Keyboard Led
  2. procedure LedLight(Light: Boolean);
  3. Var ShProcess:Tprocess;
  4. begin
  5.     ShProcess := TProcess.Create(nil);
  6.     ShProcess.Options:=[poWaitOnExit,poNoConsole];
  7.     ShProcess.Executable := 'xset';
  8.     If Light then
  9.     ShProcess.Parameters.Add('-led')
  10.     else
  11.     ShProcess.Parameters.Add('led');
  12.     ShProcess.Parameters.Add('3');
  13.     ShProcess.Execute;
  14.     ShProcess.Free;
  15. end;
  16.  

Guva

  • Jr. Member
  • **
  • Posts: 82
Re: LedKey - Switching the keyboard backlight
« Reply #2 on: September 03, 2018, 09:20:16 pm »
Not very rich program. Core is
Yes, the program is small and what else is needed to turn on the keyboard backlight ? The most important thing here is to intercept scroll lock using codebot.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: LedKey - Switching the keyboard backlight
« Reply #3 on: September 03, 2018, 09:33:43 pm »
Not very rich program. Core is
Yes, the program is small and what else is needed to turn  the keyboard backlight ? The most important thing here is to intercept scroll lock using codebot.

I think the point Alex is trying to make is that your program does (almost) nothing but call xset. It is alright ... as an example of how to call an external program, little more. <shrugs>

ETA: Also, do note that xset led 3 will turn the backlight only on your computer and similar ones. In other types it may switch NumLock, or ScrollLock, or anything switchable ... or do nothing at all, like it does--rather doesn't do :) ---in mine.

It's an ingenous little thing---most of all because all she does for so little result---but as said above: it's basically an example program. :P
« Last Edit: September 03, 2018, 10:06:04 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: LedKey - Switching the keyboard backlight
« Reply #4 on: September 03, 2018, 10:06:17 pm »
I wholeheartedly agree!
Specialize a type, not a var.

Guva

  • Jr. Member
  • **
  • Posts: 82
Re: LedKey - Switching the keyboard backlight
« Reply #5 on: September 04, 2018, 05:13:49 am »
Quote
Also, do note that xset led 3 will turn the backlight only on your computer and similar ones. In other types it may switch NumLock, or ScrollLock, or anything switchable ... or do nothing at all, like it does--rather doesn't do :) ---in mine.
well, you will not put the program for video capture if you do not have a video capture Board?  :P
"example program." totally agree !
First of all, I did it for myself. I'm tired of switching lights from the console. And the solutions I found weren't very good.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: LedKey - Switching the keyboard backlight
« Reply #6 on: September 04, 2018, 02:52:42 pm »
well, you will not put the program for video capture if you do not have a video capture Board?  :P
"example program." totally agree !

The point was that it isn't guaranteed that xset [-]led 3 will affect backlight. Make it configurable, at least, or investigate xset led name "...". If you want to generalize.

First of all, I did it for myself. I'm tired of switching lights from the console. And the solutions I found weren't very good.

Yes, that's how most small programs are born: "I'm tired of ..." and "solutions not good!" :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018