File tree Expand file tree Collapse file tree 5 files changed +75
-6
lines changed Expand file tree Collapse file tree 5 files changed +75
-6
lines changed Original file line number Diff line number Diff line change 1
1
cmake_minimum_required (VERSION 3.12)
2
2
project (thinkpad_keyboard_backlight)
3
- set (CMAKE_INSTALL_PREFIX /usr/local/ bin)
3
+ set (CMAKE_INSTALL_PREFIX /usr/bin)
4
4
5
5
6
6
set (CMAKE_CXX_STANDARD 17)
@@ -30,6 +30,8 @@ set(CMAKE_CXX_FLAGS "${OPTIMIZATION_LEVEL} \
30
30
-Wpedantic \
31
31
-Wextra" )
32
32
33
+ set (SERVICE_TARGET_PATH /etc/systemd/system /keyboard_backlight.service)
34
+ set (APP_TARGET_PATH ${CMAKE_INSTALL_PREFIX} /keyboard_backlight)
33
35
34
36
find_package (Threads)
35
37
@@ -40,10 +42,12 @@ target_link_libraries (keyboard_backlight ${CMAKE_THREAD_LIBS_INIT})
40
42
41
43
install (TARGETS keyboard_backlight DESTINATION ${CMAKE_INSTALL_PREFIX} )
42
44
43
-
44
- # Add custom features to build hex, bin or lst files.
45
45
add_custom_target (service
46
46
DEPENDS keyboard_backlight
47
47
COMMAND sudo cp ${CMAKE_CURRENT_SOURCE_DIR} /keyboard_backlight.service /etc/systemd/system &&
48
48
sudo systemctl enable --now keyboard_backlight.service
49
- )
49
+ )
50
+
51
+ add_custom_target (uninstall
52
+ COMMAND sudo rm -f ${SERVICE_TARGET_PATH} ${APP_TARGET_PATH}
53
+ )
Original file line number Diff line number Diff line change
1
+ # Maintainer: Alexander Mohr keyboard_backlight at mohr dot io
2
+
3
+ pkgname=tp-kb-backlight-git
4
+ pkgver=1.0
5
+ pkgrel=1
6
+ pkgdesc=' Automated keyboard backlight'
7
+ arch=(' x86_64' )
8
+ url=' https://github.com/alexmohr/keyboard-backlight'
9
+ license=(' MIT' )
10
+ depends=(' libinput' )
11
+ makedepends=(' git' ' cmake' ' gcc' )
12
+
13
+ source=(" git+https://github.com/alexmohr/keyboard-backlight" )
14
+ sha512sums=(' SKIP' )
15
+
16
+
17
+ build () {
18
+ cd " keyboard-backlight"
19
+ mkdir build -p
20
+ cd build
21
+ cmake ..
22
+ make
23
+ }
24
+
25
+ package () {
26
+ appname=' keyboard_backlight'
27
+ install -Dm 755 " keyboard-backlight/build/${appname} " " ${pkgdir} /usr/bin/${appname} "
28
+ install -Dm 644 " keyboard-backlight/keyboard_backlight.service" " ${pkgdir} /etc/systemd/system/keyboard_backlight.service"
29
+
30
+ echo " Please enable the systemd service via 'sudo systemctl enable --now keyboard_backlight.service"
31
+ echo " The service file can be used for configuration."
32
+ echo " See 'keyboard_backlight -h' for options" .
33
+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,11 @@ backlight of a keyboard. It's only tested for thinkpads but may work on
6
6
other devices as well
7
7
8
8
## Installation
9
+
10
+ ### Arch Linux
11
+ The package is in the AUR and called `` tp-kb-backlight-git ``
12
+
13
+ ### Install from source
9
14
To build the binary run
10
15
````
11
16
mkdir build
@@ -19,6 +24,32 @@ to install the service and enable the systemd service.
19
24
20
25
Make sure to run `` make install `` BEFORE `` make service ``
21
26
27
+ ### Binary (not recommended)
28
+ Download the latest package from github. Extract it an run the following commands.
29
+
30
+ ````
31
+ sudo cp keyboard_backlight /usr/bin
32
+ sudo cp keyboard_backlight.service /etc/systemd/sytem
33
+ sudo systemctl enable --now keyboard_backlight.service
34
+ ````
35
+
36
+
37
+ # Uninstall
38
+ For automated removal run the command below in the cmake folder
39
+ ````
40
+ make uninstall
41
+ ````
42
+
43
+ To manually delete the files
44
+ ````
45
+ sudo systemctl disable --now keyboard_backlight.service
46
+ sudo rm /etc/systemd/system/keyboard_backlight.service
47
+ sudo rm /usr/bin/keyboard_backlight
48
+ ````
49
+
50
+
51
+
52
+
22
53
## Configuration
23
54
````
24
55
tp_kbd_backlight help
Original file line number Diff line number Diff line change @@ -331,7 +331,8 @@ int main(int argc, char **argv) {
331
331
if (!file_read_uint64 (brightnessPath, &originalBrightness_)
332
332
|| !file_write_uint64 (brightnessPath, originalBrightness_)
333
333
) {
334
- std::cout << " failed to get/set brightness " << std::endl;
334
+ std::cout << " Write access to brightness device descriptor failed.\n "
335
+ " Please run with root privileges" << std::endl;
335
336
exit (EXIT_FAILURE);
336
337
}
337
338
currentBrightness_ = originalBrightness_;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ Description=Controls the backlight of the keyboard
4
4
[Service]
5
5
Type =forking
6
6
# Options can be passed via command line
7
- ExecStart =/usr/local/ bin/keyboard_backlight -t 5
7
+ ExecStart =/usr/bin/keyboard_backlight -t 5
8
8
9
9
[Install]
10
10
WantedBy =default.target
You can’t perform that action at this time.
0 commit comments