mpalourdio / xps13

:neckbeard: DELL xps13 2015 (9343) Linux Support
324 stars 24 forks source link

Keyboard back-light on at boot and resume #75

Closed rosolko closed 8 years ago

rosolko commented 8 years ago

Related to this post and solution

Workaround: 1: Save script to

/usr/local/bin/xps13-kbd-backlight

Make it as executable

sudo chmod +x <script>

2: Problem part 3: Link to /etc/pm/sleep.d

ln -s  /usr/bin/xps13-kbd-backlight /etc/pm/sleep.d/20_xps13-kbd-backlight

A problem: Partially this solution is working - if talking about back-light on resume, but on boot - I have no luck.

The problem is in this part of the solution:

using preferences set in ${BL_CONF}
[/etc/xps13-kbd-backlight]

How can I set this value?

r2rien commented 8 years ago

As commented in my script, https://askubuntu.com/questions/689907/dell-xps-13-9343-keyboard-backlight-on-at-boot-ubuntu-15-10/711291#711291

You have to edit files with its path in between [], removing prefix #~ at begining of lines

resulting content of file [/etc/xps13-kbd-backlight] (edited with command sudo nano /etc/xps13-kbd-backlight)

## 0 : off
## 1 : min
## 2 : max
default=0
current=1

resulting content of file [/etc/xdg/autostart/xps13-kbd-backlight.desktop] (edited with command sudo nano /etc/xdg/autostart/xps13-kbd-backlight.desktop)

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=xps13-kbd-backlight
X-GNOME-Autostart-enabled=true
X-GNOME-Autostart-Phase=Initialization
Icon=keyboard
Name=xps13-kbd-backlight
Comment=set/restore xps13-kbd-backlight
Categories=Utility;
r2rien commented 8 years ago
BL_CONF=/etc/xps13-kbd-backlight

can be set to another path at your convenience:

BL_CONF=/path/at/your/convenience
rosolko commented 8 years ago

Well, create all of the files. But, where should I set BL_CONF value? What command should I use to set them? Or what file should be changed to set value?

ikuria commented 8 years ago

i want a script for each present: backlight 100% on AC backlight x% on BAT (change it on the fly)

mpalourdio commented 8 years ago

Maybe it's possible for TLP to add custom events.

ikuria commented 8 years ago

/etc/pm/power.d/run_after_pwrmanagmt.sh

case "${1}" in true) #battery_mode xinput set-int-prop 12 277 8 2 3 0 0 1 3 2 echo 1 > /sys/class/backlight/intel_backlight/brightness ;; false) #ac_mode xinput set-int-prop 12 277 8 2 3 0 0 1 3 2 echo 937 > /sys/class/backlight/intel_backlight/brightness esac

i do that

rosolko commented 8 years ago

Good work!

But, what about this question related to comment

ikuria commented 8 years ago

BL_CONF is set in the script in the first line behind the comments with # infront https://askubuntu.com/questions/689907/dell-xps-13-9343-keyboard-backlight-on-at-boot-ubuntu-15-10/711291#711291

rosolko commented 8 years ago

Ok I see. But why I have no luck with restoring keyboard back-light on the OS start?

ikuria commented 8 years ago

create a script that perform "echo 2 > /sys/class/leds/dell::kbd_backlight/brightness" at your os start as root, just simple, i'm happy with off as default and press fn+f10 if i need light on the keys

rosolko commented 8 years ago

Can I just place this script into /etc/init.d to work?

ikuria commented 8 years ago

use /etc/rc.local

rosolko commented 8 years ago

The content of the /etc/rc.local now is:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo 2 > /sys/class/leds/dell::kbd_backlight/brightness
rfkill block bluetooth
exit 0

And the back-light is turn on by start :C

ikuria commented 8 years ago

and you want to disable it on start? then change the value from 2 to 0 - 1 is for the 50% lightlevel

rosolko commented 8 years ago

Just looking onto behavior of the content of the /sys/class/leds/dell::kbd_backlight/brightness in accordance with light options - seems like for turning off light respond 0 value.

rosolko commented 8 years ago

Have no luck again even after changing value to 0. PC start with maximum back-light brightness level.

ikuria commented 8 years ago

but the command worked as root in terminal? "echo 0 > /sys/class/leds/dell::kbd_backlight/brightness" worked for me without problem

rosolko commented 8 years ago
overlord@moon:~$ sudo echo 0 > /sys/class/leds/dell::kbd_backlight/brightness
bash: /sys/class/leds/dell::kbd_backlight/brightness: Permission denied

Little confused :|

ikuria commented 8 years ago

sudo su password echo 0 > /sys/class/leds/dell::kbd_backlight/brightness

rosolko commented 8 years ago
sudo su
password
echo 0 > /sys/class/leds/dell::kbd_backlight/brightness

In this case it's work.

ikuria commented 8 years ago

so test the lines like:

echo 0 > /sys/class/leds/dell::kbd_backlight/brightness & rfkill block bluetooth & exit 0

in rc.local

rosolko commented 8 years ago
echo 0 > /sys/class/leds/dell::kbd_backlight/brightness &
rfkill block bluetooth &
exit 0

Doesn't work.

One more question: Relate to original script - we create and save as executable script to /usr/local/bin/xps13-kbd-backlight but later we create link to /usr/bin/xps13-kbd-backlight with /etc/pm/sleep.d/20_xps13-kbd-backlight is it correct?

brunano21 commented 8 years ago

@rosolko so did you solve?

rosolko commented 8 years ago

@brunano21 Yes. After fresh system install this solution completely solve my problem. Complete solution and script available on askubuntu.

brunano21 commented 8 years ago

@rosolko do you refers to this?

Can you pastebin your script?

Because I have done like in the AskUbuntu thread, but still getting on when booting and resuming. :/

Also,

    br1@br1-xps13-9343:~$ ll /etc/pm/sleep.d/
    total 20
    ...
    lrwxrwxrwx 1 root root   34 May  2 10:39 20_xps13-kbd-backlight -> /usr/local/bin/xps13-kbd-backlight*
    ...

Is it a matter of permission maybe?