Skip to content

Commit

Permalink
Disabled root check, added guide for rootless config
Browse files Browse the repository at this point in the history
  • Loading branch information
Nortank12 committed Sep 15, 2024
1 parent a364331 commit 0b8ecb8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ edition = "2021"

[dependencies]
libloading = "0.8.5"
libc = "0.2.158"
hidapi = "2.6.3"
cpu-monitor = "0.1.1"
clap = { version = "4.5.16", features = ["derive"] }
Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,27 @@ Options:

```

### Rootless mode
If you need to run the program without root privilege, you can create a `udev` rule to access all necessary resources as a user.

1. Locate your directory, it can be `/lib/udev/rules.d` or `/etc/udev/rules.d`.
```bash
cd /lib/udev/rules.d
```
2. Create a new file called `99-deepcool-digital.rules`.
```bash
sudo nano 99-deepcool-digital.rules
```
3. Copy the contents:
```bash
# Intel RAPL energy usage file
ACTION=="add", SUBSYSTEM=="powercap", KERNEL=="intel-rapl:0", RUN+="/bin/chmod 444 /sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj"

# DeepCool HID raw devices
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="3633", MODE="0666"
```
4. Reboot your computer.

# Automatic start

## Systemd (Arch, Debian, Ubuntu, Fedora, etc.)
Expand Down Expand Up @@ -125,7 +146,7 @@ sudo systemctl enable deepcool-digital
```
*Note: The program will run automatically after the next boot.*

## OpenRC (Gentoo)
## OpenRC (Gentoo, Artix Linux, etc.)
1. Copy the `deepcool-digital-linux` to the `/usr/sbin/` folder.
```bash
sudo cp ./deepcool-digital-linux /usr/sbin/
Expand Down
9 changes: 0 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ mod monitor;

use clap::Parser;
use hidapi::HidApi;
use libc::geteuid;
use std::process::exit;

const VENDOR: u16 = 0x3633;
Expand All @@ -25,14 +24,6 @@ struct Args {
}

fn main() {
// Check root
unsafe {
if geteuid() != 0 {
println!("Try to run the program as root!");
exit(1);
}
}

// Read args
let args = Args::parse();
if !["temp", "usage", "auto"].contains(&args.mode.as_str()) {
Expand Down

0 comments on commit 0b8ecb8

Please sign in to comment.