Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
deepin开启笔记本键盘背光灯
Experiences and Insight
1674
views ·
0
replies ·
To
floor
Go
150******77
deepin
2018-08-27 01:57
Author
本本是华硕zx50j游戏本,拥有键盘背光灯,Deepin下fn+f3/fn+f4无法调整背光灯.最近换了个透明键盘膜,于是看看能否弄一下键盘灯.一开始想找找有没有相关驱动,发现没有.继续翻资料,发现org.freedesktop.UPower.KbdBacklight这东西,上他官网找了找,貌似有戏.
https://upower.freedesktop.org/docs/ref-dbus.html
看了下就三个api, GetMaxBrightness, GetBrightness, SetBrightness,
具体说明见他网页
,很明显就他了,既然是dbus api,那就很好办了,直接用dbus-send就可以搞事
dbus-send [--help] [--system | --session | --bus=ADDRESS | --peer=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] [contents ...]
剩下的就是写脚本的事了
#!/bin/bash
if [[ $# -lt 1 ]]; then
echo -e "\033[0;31mUsage: $0 <+|->\033[0m"
exit -1
fi
MaxBrightness=`dbus-send --system --print-reply=literal --type=method_call --dest="org.freedesktop.UPower" "/org/freedesktop/UPower/KbdBacklight" "org.freedesktop.UPower.KbdBacklight.GetMaxBrightness" | sed 's/int32//g'`
NowBrightness=`dbus-send --system --print-reply=literal --type=method_call --dest="org.freedesktop.UPower" "/org/freedesktop/UPower/KbdBacklight" "org.freedesktop.UPower.KbdBacklight.GetBrightness" | sed 's/int32//g'`
if [[ $1 == '+' && $NowBrightness < $MaxBrightness ]]; then
dbus-send --system --print-reply=literal --type=method_call --dest="org.freedesktop.UPower" "/org/freedesktop/UPower/KbdBacklight" "org.freedesktop.UPower.KbdBacklight.SetBrightness" int32:$(expr $NowBrightness + 1)
elif [[ $1 == '-' && $NowBrightness > 0 ]]; then
dbus-send --system --print-reply=literal --type=method_call --dest="org.freedesktop.UPower" "/org/freedesktop/UPower/KbdBacklight" "org.freedesktop.UPower.KbdBacklight.SetBrightness" int32:$(expr $NowBrightness - 1)
fi
Copy the Code
传入参数为+或者-,表示增加或者降低亮度,然后添加到自定义快捷键,快捷键fn键用不了,故用super + f3/super + f4代替,完事
Reply
Like 0
Favorite
View the author
All Replies
No replies yet
Please
sign
in first
Featured Collection
Change
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
【Enhanced Repo】Better Deepin Repo is released
Popular Events
More
看了下就三个api, GetMaxBrightness, GetBrightness, SetBrightness,具体说明见他网页,很明显就他了,既然是dbus api,那就很好办了,直接用dbus-send就可以搞事
dbus-send [--help] [--system | --session | --bus=ADDRESS | --peer=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] [contents ...]
剩下的就是写脚本的事了