Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions i18n/en/cachyos_hello.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ tweak-bpftune-tooltip = Automatically tune system network
tweak-bluetooth-tooltip = Enable support for Bluetooth wireless devices (mice, audio, etc.)
tweak-ananicycpp-tooltip = Auto-adjust process priorities for better system responsiveness
tweak-cachyupdate-tooltip = Update notifier in tray
tweak-refreshswitch-tooltip = Auto-switch display refresh rate on battery (low Hz) and AC (high Hz) for laptops

# Tweaks page (fixes)
remove-lock-title = Remove db lock
Expand Down
306 changes: 306 additions & 0 deletions refresh-switch/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions refresh-switch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "refresh-switch"
version = "0.1.0"
edition = "2024"

[dependencies]
dbus = "0.9"
ctrlc = "3.4"
serde = { version = "1", features = ["derive"] }
serde_json = "1"

[profile.release]
opt-level = "z"
lto = true
codegen-units = 1
strip = true
panic = "abort"
60 changes: 60 additions & 0 deletions refresh-switch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# refresh-switch

Auto-switch display refresh rate on laptops based on power source (AC/battery).

## How it works

- Listens for UPower D-Bus signals (zero polling)
- **AC power**: switches built-in display to the highest available refresh rate
- **Battery**: switches to the lowest available refresh rate
- External monitors are never touched (they have their own power supply)
- Auto-detects desktop environment, monitor, and available refresh rates

## Supported desktops

| Desktop | Backend | Tool |
|---------|---------|------|
| Hyprland | `hyprctl monitors -j` / `hyprctl keyword monitor` | hyprctl |
| KDE Plasma | `kscreen-doctor -j` / `kscreen-doctor output...` | libkscreen |
| GNOME | `gnome-randr` or `gnome-monitor-config` | gnome-randr / gnome-monitor-config |

Desktop is auto-detected from `XDG_CURRENT_DESKTOP`.

## Installation

```bash
cargo build --release
cp target/release/refresh-switch ~/.local/bin/
cp refresh-switch.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable --now refresh-switch.service
```

## Usage

```bash
# Check status
systemctl --user status refresh-switch.service

# View logs
journalctl --user -u refresh-switch.service -f

# Run manually (for testing)
./target/release/refresh-switch
```

## Dependencies

- UPower (D-Bus) -- power state monitoring
- systemd -- service management
- One of the following (auto-detected):
- **Hyprland**: `hyprctl`
- **KDE Plasma**: `kscreen-doctor` (from `libkscreen`)
- **GNOME**: `gnome-randr` or `gnome-monitor-config`

## Design

- Only built-in displays (eDP connectors) are switched
- Refresh rates are auto-detected from the monitor's supported modes
- Nothing is hardcoded -- works on any laptop with any resolution/refresh rates
- Lightweight: ~1MB memory, near-zero CPU usage
Loading