-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rouven Spreckels
committed
Jun 7, 2019
1 parent
5f35311
commit da048fe
Showing
27 changed files
with
229 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Copyright (c) 2019 Rouven Spreckels <[email protected]> | ||
# | ||
# Usage of the works is permitted provided that | ||
# this instrument is retained with the works, so that | ||
# any entity that uses the works is notified of this instrument. | ||
# | ||
# DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. | ||
|
||
ETC := /etc/default/huawei-wmi/ | ||
SYS := /sys/devices/platform/huawei-wmi/ | ||
|
||
.PHONY: off | ||
off: | ||
@echo 0 100 | tee $(ETC)charge_thresholds $(SYS)charge_thresholds | ||
|
||
.PHONY: travel | ||
travel: | ||
@echo 95 100 | tee $(ETC)charge_thresholds $(SYS)charge_thresholds | ||
|
||
.PHONY: office | ||
office: | ||
@echo 70 90 | tee $(ETC)charge_thresholds $(SYS)charge_thresholds | ||
|
||
.PHONY: home | ||
home: | ||
@echo 40 70 | tee $(ETC)charge_thresholds $(SYS)charge_thresholds | ||
|
||
.PHONY: lock | ||
lock: | ||
@echo 0 | tee $(SYS)fn_lock_state | ||
|
||
.PHONY: unlock | ||
unlock: | ||
@echo 1 | tee $(SYS)fn_lock_state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Copyright (c) 2019 Rouven Spreckels <[email protected]> | ||
# | ||
# Usage of the works is permitted provided that | ||
# this instrument is retained with the works, so that | ||
# any entity that uses the works is notified of this instrument. | ||
# | ||
# DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. | ||
|
||
include ../common.mk | ||
|
||
PKG := huawei-wmi | ||
VER := 0.1.0 | ||
GEN := ../generic/huawei-wmi-0.1.0/ | ||
SRC := $(PKG)-$(VER)/ | ||
DSC := $(PKG)_$(VER).dsc | ||
DEB := $(PKG)_$(VER)_all.deb | ||
|
||
.PHONY: all | ||
all: $(DEB) | ||
|
||
.PHONY: install | ||
install: $(DEB) | ||
dpkg --install $(DEB) | ||
|
||
.PHONY: remove | ||
remove: | ||
dpkg --remove $(PKG) | ||
|
||
.PHONY: purge | ||
purge: | ||
dpkg --purge $(PKG) | ||
|
||
.PHONY: reconfigure | ||
reconfigure: | ||
dpkg-reconfigure $(PKG) | ||
|
||
.PHONY: clean | ||
clean: | ||
cd $(SRC) && dpkg-buildpackage --no-sign --post-clean | ||
rm --force $(CPY) | ||
|
||
.PHONY: distclean | ||
distclean: clean | ||
rm --force *.deb | ||
rm --force *.buildinfo | ||
rm --force *.changes | ||
rm --force *.dsc | ||
rm --force *.xz | ||
|
||
.PHONY: translate | ||
translate: | ||
cd $(SRC) && debconf-updatepo | ||
|
||
CPY := $(SRC)README.md | ||
CPY += $(SRC)10-huawei-wmi.rules | ||
CPY += $(SRC)debian/huawei-wmi-privilege.service | ||
CPY += $(SRC)debian/huawei-wmi-reinstate.service | ||
|
||
$(DEB): $(CPY) $(shell find $(SRC) | grep -vFf .gitignore) | ||
cd $(SRC) && dpkg-buildpackage --no-sign | ||
touch $@ | ||
lintian $(DSC) | ||
lintian $(DEB) | ||
|
||
$(SRC)README.md: $(GEN)README.md | ||
cp -a $< $@ | ||
|
||
$(SRC)10-huawei-wmi.rules: $(GEN)10-huawei-wmi.rules | ||
cp -a $< $@ | ||
|
||
$(SRC)debian/huawei-wmi-privilege.service: $(GEN)huawei-wmi-privilege.service | ||
cp -a $< $@ | ||
|
||
$(SRC)debian/huawei-wmi-reinstate.service: $(GEN)huawei-wmi-reinstate.service | ||
cp -a $< $@ | ||
|
||
Makefile:; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# huawei-wmi | ||
|
||
Sets group write privileges and reinstates battery charging-thresholds. | ||
|
||
## Debian Package | ||
|
||
Tested on Debian Buster. | ||
|
||
Requirements: | ||
|
||
* `build-essential` | ||
* `devscripts` | ||
* `debhelper` | ||
|
||
Build package: `make` | ||
|
||
Install package: `sudo make install` | ||
|
||
Remove package: `sudo make remove` | ||
|
||
Reconfigure installed package: `sudo make reconfigure` | ||
|
||
Clean package directory: `make clean` | ||
|
||
Clean all: `make distclean` | ||
|
||
Translate templates: `make translate` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright (c) 2019 Rouven Spreckels <[email protected]> | ||
# | ||
# Usage of the works is permitted provided that | ||
# this instrument is retained with the works, so that | ||
# any entity that uses the works is notified of this instrument. | ||
# | ||
# DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. | ||
|
||
include ../common.mk | ||
|
||
SRC := huawei-wmi-0.1.0/ | ||
|
||
UDEV := /lib/udev/rules.d/ | ||
SYSTEMD := /lib/systemd/system/ | ||
|
||
SHELL := /bin/sh | ||
|
||
.PHONY: all | ||
all: | ||
|
||
.PHONY: install | ||
install: users | ||
groupadd --system huawei-wmi 2> /dev/null || true | ||
for user in $$(cat $<); do \ | ||
usermod --append --groups huawei-wmi "$$user"; \ | ||
done | ||
install -d $(ETC) | ||
install $(SRC)README.md $(ETC) | ||
chmod g+s $(ETC) | ||
chgrp huawei-wmi $(ETC) | ||
[ -e $(ETC)/charge_thresholds ] || { \ | ||
cat $(SYS)/charge_thresholds 2> /dev/null || echo 0 100; \ | ||
} > $(ETC)/charge_thresholds | ||
chmod g=u $(ETC)charge_thresholds | ||
install $(SRC)10-huawei-wmi.rules $(UDEV) | ||
install $(SRC)huawei-wmi-privilege.service $(SYSTEMD) | ||
install $(SRC)huawei-wmi-reinstate.service $(SYSTEMD) | ||
systemctl daemon-reload | ||
systemctl enable huawei-wmi-privilege huawei-wmi-reinstate | ||
udevadm control --reload-rules && udevadm trigger --action=add || true | ||
|
||
.PHONY: reconfigure | ||
reconfigure: clean install | ||
|
||
users: | ||
@echo "Please list the users who are allowed to change WMI settings, such" | ||
@echo "as the battery charge-thresholds and the Fn-lock state. You probably" | ||
@echo "want to to list your desktop users." | ||
@echo | ||
@read -p "List of users separated by space: " users; echo "$$users" > $@ | ||
|
||
.PHONY: remove | ||
remove: | ||
systemctl disable huawei-wmi-reinstate huawei-wmi-privilege || true | ||
rm --force $(ETC)README.md | ||
rm --force $(ETC)charge_thresholds | ||
rmdir $(ETC) || true | ||
rm --force $(UDEV)10-huawei-wmi.rules | ||
rm --force $(SYSTEMD)huawei-wmi-privilege.service | ||
rm --force $(SYSTEMD)huawei-wmi-reinstate.service | ||
groupdel huawei-wmi || true | ||
|
||
.PHONY: clean | ||
clean: | ||
@rm --force users | ||
|
||
Makefile:; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# huawei-wmi | ||
|
||
Sets group write privileges and reinstates battery charging-thresholds. | ||
|
||
## Generic Makefile | ||
|
||
Tested on Debian Buster. | ||
|
||
Install: `sudo make install` | ||
|
||
Remove: `sudo make remove` | ||
|
||
Reconfigure then install: `sudo make reconfigure` | ||
|
||
Clean users: `make clean` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.