-
-
Notifications
You must be signed in to change notification settings - Fork 695
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now that we support managing three different kinds of hardware, I think it's time for us to ship our own udev rules + script, instead of asking people to paste a random script and udev rules in each of the widget docs. Hopefully this means things will Just Work for people installing via distro packaging, but because of virtualenvs, people installing from source may have to do a bit of extra fiddling. (Is there a better way than adding another script? Like a virtualenv one liner that will set up the virtual env and invoke qtile?) Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
- Loading branch information
Showing
8 changed files
with
122 additions
and
46 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
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,43 @@ | ||
import argparse | ||
import glob | ||
import os | ||
import shutil | ||
import stat | ||
|
||
MODE = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH | ||
|
||
|
||
def set_file_perms(p, options): | ||
try: | ||
os.chmod(p, MODE) | ||
shutil.chown(p, user=None, group=options.group) | ||
except FileNotFoundError: | ||
pass | ||
|
||
|
||
def do_backlight_setup(options): | ||
set_file_perms("/sys/class/backlight/{}/brightness".format(options.device), options) | ||
set_file_perms("/sys/class/leds/{}/brightness".format(options.device), options) | ||
|
||
|
||
def do_battery_setup(options): | ||
files = glob.glob("/sys/class/power_supply/BAT*/charge_control_*_threshold") | ||
for file in files: | ||
set_file_perms(file, options) | ||
|
||
|
||
def udev(options): | ||
if options.kind == "backlight": | ||
do_backlight_setup(options) | ||
elif options.kind == "battery": | ||
do_battery_setup(options) | ||
else: | ||
raise "Unknown udev option {}".format(options.kind) | ||
|
||
|
||
def add_subcommand(subparsers, parents): | ||
parser = subparsers.add_parser("udev", parents=parents, help=argparse.SUPPRESS) | ||
parser.add_argument("kind", choices=["backlight", "battery"]) | ||
parser.add_argument("--device") | ||
parser.add_argument("--group", default="sudo") | ||
parser.set_defaults(func=udev) |
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
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,26 @@ | ||
# for controlling LCD backlight | ||
ACTION=="add", SUBSYSTEM=="backlight", RUN+="qtile udev --group sudo backlight --device %k" | ||
|
||
# keyboard backlight | ||
ACTION=="add", SUBSYSTEM=="leds", RUN+="qtile udev --group sudo backlight --device %k" | ||
|
||
# fancy battery charge control, needs to be per ACPI implementation, so we need | ||
# to periodically check the kernel for more of these: | ||
# | ||
# $ ~/packages/linux/drivers/platform/x86 master git grep -l charge_control_end_threshold | ||
# asus-wmi.c | ||
# huawei-wmi.c | ||
# lg-laptop.c | ||
# msi-ec.c | ||
# system76_acpi.c | ||
# thinkpad_acpi.c | ||
# toshiba_acpi.c | ||
# | ||
# Last checked as of 6.8-rc4. | ||
ACTION=="add" KERNEL=="asus-wmi" RUN+="qtile udev --group sudo battery" | ||
ACTION=="add" KERNEL=="huawei-wmi" RUN+="qtile udev --group sudo battery" | ||
ACTION=="add" KERNEL=="lg-laptop" RUN+="qtile udev --group sudo battery" | ||
ACTION=="add" KERNEL=="msi-ec" RUN+="qtile udev --group sudo battery" | ||
ACTION=="add" KERNEL=="thinkpad_acpi" RUN+="qtile udev --group sudo battery" | ||
ACTION=="add" KERNEL=="system76_acpi" RUN+="qtile udev --group sudo battery" | ||
ACTION=="add" KERNEL=="toshiba_acpi" RUN+="qtile udev --group sudo battery" |
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