Files
DCGOS/dotfiles/.config/niri/switch_monitors.sh
dichgrem d0c16e345a fix:switch.sh&&mysql
update:flake

Version 406 -> 410:
  bat: 0.26.0 → 0.26.1, +17.6 KiB
  brave: 1.84.141 → 1.85.111, +2964.5 KiB
  hyprlang: 0.6.6 → 0.6.7
  ipxe: 1.21.1-unstable-2025-11-26 → 1.21.1-unstable-2025-12-03
  kazumi: 1.9.0 → 1.9.1, +218.1 KiB
  libbytesize: 2.11 → 2.12
  libvlc: 3.0.21 → 3.0.22, +1912.7 KiB
  mesa: 25.3.0 → 25.3.1, +52.0 KiB
  nixos-system-dos: 26.05.20251202.418468a → 26.05.20251205.f61125a
  scx_full: 1.0.18 → 1.0.19, +27223.4 KiB
  source: +548.8 KiB
  xwayland-satellite: 0.7 → 0.8, +891.4 KiB
  zed-editor: 0.214.7 → 0.215.3, +16693.9 KiB
  fastfetch: 2.55.1 → 2.56.0, +8.6 KiB
  firefox: -61.6 KiB
  firefox-unwrapped: -149.0 KiB
  gst-plugins-rs: 0.14.2 → 0.14.4, -23465.5 KiB
  initrd-linux: +8.7 KiB
  libgit2: 1.9.1 → 1.9.2
  linux: 6.18.0-modules → ∅, -2899.5 KiB
  nix: 2.31.2 → 2.31.2+1
  nix-cmd: 2.31.2 → 2.31.2+1
  nix-expr: 2.31.2 → 2.31.2+1
  nix-fetchers: 2.31.2 → 2.31.2+1
  nix-flake: 2.31.2 → 2.31.2+1
  nix-main: 2.31.2 → 2.31.2+1
  nix-store: 2.31.2 → 2.31.2+1
  nix-util: 2.31.2 → 2.31.2+1
  nixos-icons: 0-unstable-2024-04-10 → 0-unstable-2025-06-28
  nixos-system-dos: 26.05.20251205.f61125a → 26.05.20251208.addf7cf
  nss: 3.118.1 → 3.119
  python3: +216.7 KiB
  python3.12-python-lsp-server: 1.13.2 → 1.14.0
  python3.13-dbus-python: ∅ → 1.4.0, +685.3 KiB
  readest: 0.9.93 → 0.9.94, +1060.0 KiB
  ruff: 0.14.7 → 0.14.8, +87.0 KiB
  samba: 4.22.5 → 4.22.6, +15.4 KiB
  source: +201.2 KiB
  unit-script-initrd-nixos-activation: ε → ∅
  webkitgtk: 2.50.2+abi=4.1 → 2.50.3+abi=4.1
  x86_energy_perf_policy: 6.12.60 → 6.12.61
2025-12-10 22:28:05 +08:00

55 lines
1.3 KiB
Bash
Executable File
Vendored

#!/usr/bin/env bash
# ~/.config/niri/switch_monitors.sh
# 切换 Niri 下显示模式:内屏 → 外屏 → 扩展
STATE_FILE="/tmp/niri_monitor_mode"
INTERNAL="eDP-1"
EXTERNAL="DP-1"
MODES=("internal_only" "external_only" "extended")
# 读取上次模式
if [[ -f "$STATE_FILE" ]]; then
LAST_MODE=$(cat "$STATE_FILE")
else
LAST_MODE="extended"
fi
# 下一个模式
NEXT_INDEX=0
for i in "${!MODES[@]}"; do
if [[ "${MODES[$i]}" == "$LAST_MODE" ]]; then
NEXT_INDEX=$(((i + 1) % ${#MODES[@]}))
break
fi
done
NEXT_MODE="${MODES[$NEXT_INDEX]}"
# 应用模式
case "$NEXT_MODE" in
internal_only)
wlr-randr --output "$EXTERNAL" --off
wlr-randr --output "$INTERNAL" --on --mode 2560x1600 --pos 0,0 --scale 1.25
notify-send "显示模式" "仅内屏"
;;
external_only)
wlr-randr --output "$EXTERNAL" --on --mode 2560x1440@144 --pos 0,0 --scale 1.25
wlr-randr --output "$INTERNAL" --off
notify-send "显示模式" "仅外屏"
;;
extended)
wlr-randr --output "$INTERNAL" --on
notify-send "显示模式" "扩展模式"
;;
esac
echo "$NEXT_MODE" > "$STATE_FILE"
# 刷新 Niri 布局(防止残影)
sleep 0.5
niri msg reload-layout >/dev/null 2>&1 || true
pkill swayosd-server
(swayosd-server &>/dev/null &)
pkill wl-gammarelay-rs
(wl-gammarelay-rs &>/dev/null &)