Skip to content

Commit

Permalink
Merge pull request #57 from olivierlemoal/master
Browse files Browse the repository at this point in the history
Update Linux doc to run with user permissions
  • Loading branch information
haimgel authored Mar 1, 2021
2 parents a5d0b50 + d83483d commit 5f5ee6e
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,21 @@ Copy built executable:
```bash
cp target/release/display_switch /usr/local/bin
```
i2c needs root access, so run as root. Create a systemd unit file
`/etc/systemd/system/display-switch.service` with contents
Enable read/write access to i2c devices for users in `i2c` group. Run as root :

```bash
groupadd i2c
echo 'KERNEL=="i2c-[0-9]*", GROUP="i2c"' >> /etc/udev/rules.d/10-local_i2c_group.rules
udevadm control --reload-rules && udevadm trigger
```

Then add your user to the i2c group :

```
sudo usermod -aG i2c $(whoami)
```

Create a systemd unit file in your user directory (`/home/$USER/.config/systemd/user/display-switch.service`) with contents

```
[Unit]
Expand All @@ -148,18 +161,18 @@ Description=Display switch via USB switch
[Service]
ExecStart=/usr/local/bin/display_switch
Type=simple
StandardOutput=journal
Restart=always
User=root
[Install]
WantedBy=multi-user.target
WantedBy=default.target
```

Create the config file at `/root/.config/display-switch/display-switch.ini`.
Create the config file at `/home/$USER/.config/display-switch/display-switch.ini`.
Then enable the service with

```bash
systemctl daemon-reload
systemctl enable display-switch.service
systemctl start display-switch.service
systemctl --user daemon-reload
systemctl --user enable display-switch.service
systemctl --user start display-switch.service
```

0 comments on commit 5f5ee6e

Please sign in to comment.