https://github.com/bulletmark/rebind-devices
Linux service to automatically reset devices when resuming from sleep
https://github.com/bulletmark/rebind-devices
rebind service sysfs systemd
Last synced: 8 months ago
JSON representation
Linux service to automatically reset devices when resuming from sleep
- Host: GitHub
- URL: https://github.com/bulletmark/rebind-devices
- Owner: bulletmark
- Created: 2021-03-06T03:17:46.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-01-27T23:19:42.000Z (11 months ago)
- Last Synced: 2025-01-28T00:27:09.262Z (11 months ago)
- Topics: rebind, service, sysfs, systemd
- Language: Python
- Homepage:
- Size: 19.5 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## REBIND-DEVICES
[](https://aur.archlinux.org/packages/rebind-devices/)
This is a simple Linux service to automatically reset one or more
devices whenever your system resumes from sleep. The devices are
specified as [sysfs](https://man7.org/linux/man-pages/man5/sysfs.5.html)
BUS ID paths in the configuration file `/etc/rebind-devices.conf`. It
works by writing the BUS ID of the device to the [unbind and bind
files](https://lwn.net/Articles/143397/) pertaining to the associated
device driver. Use `lspci`, `lsusb -v`, etc to find the BUS ID path of a
device you want to reset, so you can add that BUS ID to your
configuration file. Your system must be using
[systemd](https://www.freedesktop.org/wiki/Software/systemd/).
I use it to reset the USB controller on my external dock whenever my
system resumes, to fix a faulty USB keyboard that otherwise does not
restore. I used `lspci | grep USB` to determine it's BUS ID.
The latest version and documentation for this utility is available at
https://github.com/bulletmark/rebind-devices.
## INSTALLATION
Arch Linux users can install [rebind-devices from the
AUR](https://aur.archlinux.org/packages/rebind-devices/) and just follow
the CONFIGURATION, ENABLE, and LOGGING sections below.
Other users should do the following to install from the source repository.
git clone http://github.com/bulletmark/rebind-devices
cd rebind-devices
sudo ./rebind-devices-setup install
## CONFIGURATION
sudo cp /usr/share/rebind-devices/rebind-devices.conf /etc/
# Add the devices you want to rebind:
sudoedit /etc/rebind-devices.conf
## ENABLE
sudo systemctl enable rebind-devices
## LOGGING
journalctl -u rebind-devices
## UPGRADE
# cd to source dir
cd rebind-devices
git pull
sudo ./rebind-devices-setup install
sudo systemctl restart rebind-devices
## DISABLE
sudo systemctl disable rebind-devices
## UNINSTALL
# cd to source dir
cd rebind-devices
sudo ./rebind-devices-setup uninstall
sudo rm /etc/rebind-devices.conf
## USAGE
Type `rebind-devices -h` to view the usage summary:
```
usage: rebind-devices [-h] [-c CONFIG]
Program to rebind configured devices after resume from suspend.
options:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
config file (default: /etc/rebind-devices.conf)
```
## LICENSE
Copyright (C) 2021 Mark Blakeney. This program is distributed under the
terms of the GNU General Public License.
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or any later
version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License at for more details.