Wren Linux

wren-linux / docs / extras / kanshi.md (as a page)

# Screens that switch by themselves (`extras/kanshi.sh`)

## SYNOPSIS

```
wrenctl install kanshi                         install it
wrenctl remove kanshi                          remove it
wrenctl manual kanshi                          print the manual steps below

swaymsg -t get_outputs                         your screens' names, for the config
~/.config/kanshi/config                        which screens are on, when
```

kanshi changes which screens are on when you plug a monitor in or out. As
installed: the laptop alone uses its own screen, and with a monitor plugged in
only the monitor is on, lid open or closed. A setup that matches neither (two
monitors, a desktop computer) is left alone, and sway keeps every screen on. The
file is yours: Wren Linux writes it only when there is none, and never replaces it.

## LIMITS

- It knows the laptop's screen as eDP-1, as most laptops (the ThinkPad T490
  among them) name it. Another name: change it in the file.
- A monitor that is plugged in but shows nothing still turns the laptop's screen
  off: unplug it to get the laptop's screen back.
- It has nothing to do with security or privacy.

## MANUAL INSTALL

```
# kanshi, from Debian
sudo apt install --no-install-recommends kanshi
# Its config: the laptop alone on its own screen, a monitor plugged in alone
mkdir -p ~/.config/kanshi
printf '%s\n' 'profile laptop {' '    output eDP-1 enable' '}' 'profile monitor {' '    output eDP-1 disable' '    output * enable' '}' >~/.config/kanshi/config
# sway starts it at every login, and again at every reload (a reload turns every
# screen on, and kanshi then puts its profile back)
echo 'exec_always sh -c '\''pkill -x -u "$(id -u)" kanshi; exec kanshi'\''' >~/.config/sway/config.d/kanshi.conf
```

To undo:

```
# sway's line, kanshi itself; your config stays
rm ~/.config/sway/config.d/kanshi.conf
pkill -x kanshi
sudo apt purge kanshi
```