1
0
Fork 0
1 Kanshi infos
Zenny edited this page 2025-10-27 20:15:43 +01:00

Monitor-Informationen herausfinden

Bevor du kanshi konfigurierst, musst du die genauen Monitor-Informationen kennen:

Option 1: Mit wlr-randr (empfohlen)

wlr-randr

Ausgabe-Beispiel:

eDP-1 "BOE 0x095F Unknown (eDP-1)" (connected)
  Physical size: 344x194 mm
  Make: BOE
  Model: 0x095F
  Serial: Unknown
  Enabled: yes
  Modes:
    1920x1080 px, 60.049000 Hz (current)
  Position: 0,0
  Transform: normal
  Scale: 1.000000

HDMI-A-2 "Dell Inc. DELL U2415 D3TM8456ABCD" (connected)
  Physical size: 520x320 mm
  Make: Dell Inc.
  Model: DELL U2415
  Serial: D3TM8456ABCD
  Enabled: yes
  Modes:
    1920x1200 px, 59.950000 Hz (current)
    1920x1080 px, 60.000000 Hz
  Position: 1920,0
  Transform: normal
  Scale: 1.000000

DP-1 "Samsung Electric Company S24C650 H4ZN123456" (connected)
  Physical size: 521x293 mm
  Make: Samsung Electric Company
  Model: S24C650
  Serial: H4ZN123456
  Enabled: yes
  Modes:
    1920x1080 px, 60.000000 Hz (current)
  Position: 3840,0
  Transform: 90
  Scale: 1.000000

Wichtige Informationen:

  • Output-Name: eDP-1, HDMI-A-2, DP-1
  • Make: Hersteller (z.B. "Dell Inc.", "Samsung Electric Company")
  • Model: Modellnummer (z.B. "DELL U2415", "S24C650")
  • Serial: Seriennummer (z.B. "D3TM8456ABCD") - wichtig für eindeutige Identifikation!

Option 2: Mit niri msg

niri msg outputs

Ausgabe-Beispiel:

Output "eDP-1"
  Make: BOE
  Model: 0x095F
  Serial: Unknown
  Current mode: 1920x1080 @ 60.049 Hz
  Position: 0,0
  Scale: 1.0
  Transform: normal

Output "HDMI-A-2"
  Make: Dell Inc.
  Model: DELL U2415
  Serial: D3TM8456ABCD
  Current mode: 1920x1200 @ 59.950 Hz
  Position: 1920,0
  Scale: 1.0
  Transform: normal

Option 3: Mit swaymsg (für Sway)

swaymsg -t get_outputs | jq '.[].make, .[].model, .[].serial'

Konfiguration

~/.config/kanshi/config:

Basis-Konfiguration (Output-Namen)

# Profil: Nur Laptop
profile laptop {
    output eDP-1 mode 1920x1080@60Hz position 0,0 scale 1.0
}

# Profil: Laptop + externer Monitor
profile docked {
    output eDP-1 mode 1920x1080@60Hz position 0,0 scale 1.5
    output HDMI-A-2 mode 1920x1080@60Hz position 1280,0 scale 1.0
}

# Profil: Nur externe Monitore (Laptop zu)
profile desktop {
    output eDP-1 disable
    output HDMI-A-2 mode 1920x1080@60Hz position 0,0 scale 1.0
    output DP-1 mode 1920x1080@60Hz position 1920,0 scale 1.0 transform 90
}

Problem: HDMI-A-2 kann verschiedene Monitore sein! Lösung: Seriennummern verwenden.


Erweiterte Konfiguration (mit Seriennummern) EMPFOHLEN

Syntax:

output "Make Model Serial" mode WxH@refresh position X,Y scale SCALE transform TRANSFORM

Vollständiges Beispiel:

# ==========================================
# Home Office Setup
# ==========================================
profile home-office {
    # Laptop-Display (integriert, keine Serial)
    output eDP-1 mode 1920x1080@60Hz position 0,0 scale 1.5

    # Dell U2415 Monitor (links)
    output "Dell Inc. DELL U2415 D3TM8456ABCD" {
        mode 1920x1200@60Hz
        position 1280,0
        scale 1.0
        transform normal
    }

    # Samsung Monitor (rechts, vertikal)
    output "Samsung Electric Company S24C650 H4ZN123456" {
        mode 1920x1080@60Hz
        position 3200,0
        scale 1.0
        transform 90
    }
}

# ==========================================
# Büro Setup
# ==========================================
profile office {
    # Laptop-Display ausschalten
    output eDP-1 disable

    # Dell Büro-Monitor (Hauptmonitor)
    output "Dell Inc. DELL P2419H 5K8RP12345AB" {
        mode 1920x1080@60Hz
        position 0,0
        scale 1.0
    }

    # Zusätzlicher Monitor (rechts)
    output "Hewlett Packard HP E243 CN12345678" {
        mode 1920x1080@60Hz
        position 1920,0
        scale 1.0
    }
}

# ==========================================
# Unterwegs / Nur Laptop
# ==========================================
profile mobile {
    output eDP-1 mode 1920x1080@60Hz position 0,0 scale 1.0
}

# ==========================================
# Gaming Setup (z.B. am TV)
# ==========================================
profile gaming {
    output eDP-1 disable

    # LG OLED TV
    output "LG Electronics LG TV SSCR2 0x01010101" {
        mode 3840x2160@60Hz
        position 0,0
        scale 2.0
    }
}

# ==========================================
# Präsentations-Setup (Beamer)
# ==========================================
profile presentation {
    # Laptop-Display an (zum Steuern)
    output eDP-1 mode 1920x1080@60Hz position 0,0 scale 1.0

    # Beamer (meist generische Info)
    output HDMI-A-1 {
        mode 1920x1080@60Hz
        position 1920,0
        scale 1.0
    }
}

Erweiterte Syntax-Optionen

Wildcards und Muster

# Jeder Dell Monitor (wenn Serial nicht wichtig)
profile any-dell {
    output "Dell Inc. *" mode 1920x1080@60Hz position 1920,0
}

# Alle Monitore auf HDMI
profile hdmi-only {
    output HDMI-A-* mode 1920x1080@60Hz position 0,0
}

Exec-Befehle (zusätzliche Aktionen)

profile home-office {
    output eDP-1 mode 1920x1080@60Hz position 0,0
    output "Dell Inc. DELL U2415 D3TM8456ABCD" mode 1920x1200@60Hz position 1920,0

    # Führe Befehle aus wenn dieses Profil geladen wird
    exec notify-send "Kanshi" "Home Office Setup aktiviert"
    exec swaybg -o eDP-1 -i ~/Bilder/wallpaper-laptop.png &
    exec swaybg -o HDMI-A-2 -i ~/Bilder/wallpaper-monitor.png &
}

Include-Direktive

# Haupt-Config: ~/.config/kanshi/config
include ~/.config/kanshi/home.conf
include ~/.config/kanshi/office.conf

Dann in separaten Dateien:

~/.config/kanshi/home.conf:

profile home-setup {
    output eDP-1 mode 1920x1080@60Hz position 0,0
    output "Dell Inc. DELL U2415 D3TM8456ABCD" mode 1920x1200@60Hz position 1920,0
}

Monitor-Matching Regeln

Kanshi wählt das erste passende Profil aus. Reihenfolge ist wichtig!

Beispiel: Spezifisch vor generisch

# ✅ RICHTIG: Spezifische Profile zuerst

# 3-Monitor Setup (sehr spezifisch)
profile triple-monitor {
    output eDP-1 disable
    output "Dell Inc. DELL U2415 D3TM8456ABCD" mode 1920x1200@60Hz position 0,0
    output "Samsung Electric Company S24C650 H4ZN123456" mode 1920x1080@60Hz position 1920,0
    output "LG Electronics 24MP88 123456789ABC" mode 1920x1080@60Hz position 3000,0
}

# 2-Monitor Setup (mittel spezifisch)
profile dual-monitor {
    output eDP-1 mode 1920x1080@60Hz position 0,0
    output "Dell Inc. DELL U2415 D3TM8456ABCD" mode 1920x1200@60Hz position 1920,0
}

# Fallback: Nur Laptop (generisch)
profile laptop-only {
    output eDP-1 mode 1920x1080@60Hz position 0,0
}
# ❌ FALSCH: Generisches Profil zuerst würde immer matchen!

profile laptop-only {
    output eDP-1 mode 1920x1080@60Hz position 0,0
}

# Wird nie erreicht, weil laptop-only immer passt
profile dual-monitor {
    output eDP-1 mode 1920x1080@60Hz position 0,0
    output "Dell Inc. DELL U2415 D3TM8456ABCD" mode 1920x1200@60Hz position 1920,0
}

Starten und Verwenden

Manuell starten

# Mit Debug-Output
kanshi -v

# Im Hintergrund
kanshi &

In niri autostart

# ~/.config/niri/config.kdl
spawn-at-startup "kanshi"

Als systemd service

Service erstellen:

mkdir -p ~/.config/systemd/user/

~/.config/systemd/user/kanshi.service:

[Unit]
Description=Dynamic display configuration
Documentation=man:kanshi(1)
PartOf=graphical-session.target

[Service]
Type=simple
ExecStart=/usr/bin/kanshi
Restart=on-failure

[Install]
WantedBy=niri.service

Service aktivieren:

systemctl --user enable kanshi.service
systemctl --user start kanshi.service
systemctl --user status kanshi.service