Skip to content

Commit 8f9c9d4

Browse files
committed
Improve systemd service + add a Makefile to install the project from source
1 parent b34fb42 commit 8f9c9d4

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Makefile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
INSTALL_PREFIX ?= /usr/local/bin
2+
3+
.PHONY: all
4+
all: target/release/backlightd target/release/backlightctl
5+
6+
target/release/backlightd: backlightd/Cargo.toml $(shell ls -1 backlightd/src/*.rs)
7+
cargo test --frozen --bin backlightd
8+
cargo build --frozen --release --bin backlightd
9+
10+
target/release/backlightctl: backlightctl/Cargo.toml $(shell ls -1 backlightctl/src/*.rs)
11+
cargo test --frozen --bin backlightctl
12+
cargo build --frozen --release --bin backlightctl
13+
14+
.PHONY: install
15+
install:
16+
install -Dm 755 -t $(INSTALL_PREFIX) target/release/backlightd
17+
install -Dm 755 -t $(INSTALL_PREFIX) target/release/backlightctl
18+
install -Dm 755 -t /etc/systemd/system backlightd.service
19+
sed -i 's+$$INSTALL_PREFIX+$(INSTALL_PREFIX)+g' /etc/systemd/system/backlightd.service
20+
systemctl daemon-reload
21+
systemctl enable backlightd
22+
systemctl restart backlightd
23+
24+
.PHONY: clean
25+
clean:
26+
rm -rf target/release

backlightd.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Description=A backlight daemon that allows you to manage the backlight of all ki
44
[Service]
55
Type=simple
66
Restart=always
7-
ExecStart=/usr/bin/backlightd
7+
ExecStart=$INSTALL_PREFIX/backlightd
88
ProtectSystem=strict
99
ReadWritePaths=/var/cache /run
1010
ProtectHome=tmpfs

0 commit comments

Comments
 (0)