User Tools

Site Tools


slackware:backlighting

Backlighting

Seemingly a perennial issue with KDE, not only do hotkey backlight changes not work (even though there are 3 or 4 different ways that they should), but whatever workaround we come up with seems to get crushed on each update. Every bug report gets marked “FIXED”, and maybe it is in the snapshots, but rest assured they'll manage to break it again before the next release.

So the fix may be slightly different each time, but here are the basics: the command that seems to actually do everything is xbacklight. A wrapper may be to some people's tastes:

#!/usr/bin/ruby
 
def die
	puts "Example usage: #{$0} +10"
	exit
end
 
die unless ARGV.length == 1
 
if ARGV[0] =~ /([+-])(\d{1,3})/
	direction = $1.to_s
	quantity = $2.to_i
else
	die
end
 
current = `xbacklight`.to_f.round.to_i
 
case direction
	when '+'
		puts 'plusify'
		new = current + quantity
	when '-'
		puts 'minusify'
		new = current - quantity
	else
		die
end
 
new = ((new/10).round)*10
 
puts "executing: xbacklight -set #{new.to_s}"
`xbacklight -set #{new.to_s}`
puts "result: " + `xbacklight`

And there's usually a working mechanism somewhere within KDE to assign keystrokes to arbitrary commands. Note that this seems to round down, somewhat randomly, so that whilst “xbacklight -set -10” generally works, “xbacklight -set 10” often does nothing. Safer to in/decrease by 20 at a time.

slackware/backlighting.txt · Last modified: 2019/11/07 17:58 by 127.0.0.1