Add TODO.md
This commit is contained in:
parent
478cd154ab
commit
9583419fd8
109
TODO.md
Normal file
109
TODO.md
Normal file
@ -0,0 +1,109 @@
|
||||
Add swayidle to make the screen go dark
|
||||
|
||||
---
|
||||
|
||||
### Step 1: Install `swayidle`
|
||||
|
||||
Open your terminal and install `swayidle` from the official Arch repositories. It's good practice to also install a screen locker like `swaylock` at the same time, as you'll likely want to lock your screen before it turns off.
|
||||
|
||||
```bash
|
||||
sudo pacman -S swayidle swaylock
|
||||
```
|
||||
|
||||
### Step 2: Create the Idle Management Script
|
||||
|
||||
It's cleanest to manage this with a small shell script. Let's create one in niri's configuration directory.
|
||||
|
||||
1. Create the file:
|
||||
```bash
|
||||
mkdir -p ~/.config/niri
|
||||
nano ~/.config/niri/idle.sh
|
||||
```
|
||||
|
||||
2. Paste the following content into the file. This configuration will do two things:
|
||||
* **After 10 minutes (600s):** Lock the screen with `swaylock`.
|
||||
* **After 15 minutes (900s):** Turn the display off (DPMS off).
|
||||
* **On resume (mouse/keyboard activity):** Turn the display back on (DPMS on).
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
|
||||
# This script is a simple wrapper for swayidle.
|
||||
# It locks the screen after 10 minutes of inactivity,
|
||||
# and turns off the display after 15 minutes.
|
||||
|
||||
swayidle -w \
|
||||
timeout 600 'swaylock -f' \
|
||||
timeout 900 'niri msg output "*" dpms off' \
|
||||
resume 'niri msg output "*" dpms on'
|
||||
```
|
||||
|
||||
* `swayidle -w`: Starts the daemon and waits (doesn't exit).
|
||||
* `timeout 600 'swaylock -f'`: After 600 seconds (10 minutes) of inactivity, run `swaylock -f` to lock the screen.
|
||||
* `timeout 900 'niri msg output "*" dpms off'`: After 900 seconds (15 minutes), run the command to turn off all outputs (`*`). The command `niri msg` is how you control niri from the command line.
|
||||
* `resume 'niri msg output "*" dpms on'`: When activity is detected again (mouse move, key press), run the command to turn all outputs back on.
|
||||
|
||||
3. Save the file and exit `nano` (Ctrl+O, Enter, Ctrl+X).
|
||||
|
||||
4. Make the script executable:
|
||||
```bash
|
||||
chmod +x ~/.config/niri/idle.sh
|
||||
```
|
||||
|
||||
### Step 3: Autostart the Script with Niri
|
||||
|
||||
Now, we need to tell niri to run this script every time it starts.
|
||||
|
||||
1. Open your niri configuration file. If it doesn't exist, niri uses its defaults, but you can create it.
|
||||
```bash
|
||||
nano ~/.config/niri/config.kdl
|
||||
```
|
||||
|
||||
2. Add the `startup-commands` block if it doesn't exist, and add an `exec-on-startup` command to run your script. Make sure to use the full path.
|
||||
|
||||
```kdl
|
||||
// Your other niri configurations might be here...
|
||||
|
||||
startup-commands {
|
||||
// Add this line to run your idle script
|
||||
exec-on-startup "~/.config/niri/idle.sh"
|
||||
|
||||
// You might have other startup commands here, for example:
|
||||
// exec-on-startup "waybar"
|
||||
// exec-on-startup "mako"
|
||||
}
|
||||
|
||||
// More of your niri config...
|
||||
```
|
||||
|
||||
**Note:** The `~` shortcut for your home directory works in the niri config.
|
||||
|
||||
3. Save and close the file.
|
||||
|
||||
### Step 4: Apply the Changes
|
||||
|
||||
Log out of your niri session and log back in. The `idle.sh` script will now be running in the background. Your screen will lock after 10 minutes and turn off after 15 minutes of inactivity. Moving your mouse or pressing a key will wake the screen up to the `swaylock` prompt.
|
||||
|
||||
---
|
||||
|
||||
### Customization
|
||||
|
||||
* **To only turn off the screen (no lock):**
|
||||
If you *only* want the screen to go black after 15 minutes and don't want to lock it, modify your `~/.config/niri/idle.sh` script to remove the `swaylock` timeout:
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
|
||||
swayidle -w \
|
||||
timeout 900 'niri msg output "*" dpms off' \
|
||||
resume 'niri msg output "*" dpms on'
|
||||
```
|
||||
This directly addresses your original request.
|
||||
|
||||
* **Changing the time:**
|
||||
Simply change the number of seconds in the script. For example, for a 5-minute screen-off time, change `900` to `300`.
|
||||
|
||||
* **Customizing swaylock:**
|
||||
You can make `swaylock` look nicer. For example, to set a solid color:
|
||||
`swaylock -f -c 000000` (for black).
|
||||
You can edit this command directly in your `idle.sh` script. Check `man swaylock` for all options.
|
||||
Loading…
x
Reference in New Issue
Block a user