This commit is contained in:
2026-03-31 20:13:15 +08:00
parent 48044e957d
commit 08c513b995
1155 changed files with 79920 additions and 0 deletions

View File

@ -0,0 +1,362 @@
//这个文件是快捷键设置
binds {
// 显示快捷键教程
Mod+Shift+Slash hotkey-overlay-title="快捷键教程 Keybind tutorial" { spawn "~/.config/niri/scripts/niri-binds"; }
// alt+tab切换窗口
Alt+Tab hotkey-overlay-title="快速跳转窗口 Quick window switch menu" {spawn "~/.config/niri/scripts/niri-quick-switch-fuzzel.py";}
Mod+F1 hotkey-overlay-title="开关输入法 Toggle fcitx" {spawn-sh "pkill fcitx5 || fcitx5 ";}
Mod+F2 hotkey-overlay-title=null {spawn-sh "pkill cava || true && pkill waybar || true && waybar -c $HOME/.config/waybar/config.jsonc -s $HOME/.config/waybar/style.css ";}
Mod+F5 hotkey-overlay-title="快速存档 Quick save" {spawn "quicksave";}
Mod+F8 hotkey-overlay-title="快速读档 Quick load" {spawn "quickload";}
Mod+F9 hotkey-overlay-title="切换护眼模式 Toggle sunset" {spawn "~/.config/niri/scripts/toggle-wlsunset";}
// 这一行是关闭waybar进程释放资源占用。在意资源占用的时候使用。
Mod+F4 hotkey-overlay-title="开关任务栏 Toggle bar" {spawn-sh "pkill waybar || waybar ";}
// 这一行是用waybar自己支持的信号功能隐藏waybar但进程没有退出资源占用依旧有
Mod+Shift+F4 hotkey-overlay-title="隐藏任务栏 Hide bar" {spawn-sh "killall -SIGUSR1 waybar";}
// 临时开一个浮动终端
Mod+Slash hotkey-overlay-title="临时终端 Quick Terminal" {spawn "footclient" "-a" "quickterminal";}
//打开浏览器
Mod+B hotkey-overlay-title="浏览器 Browser" { spawn "firefox"; }
// Suggested binds for running programs: terminal, app launcher, screen locker.
Mod+T hotkey-overlay-title="终端 Terminal" { spawn "footclient"; }
// 文档管理器。如果有thunar的话会优先打开thunar没有的话会打开nautilus不要问我为什么
Mod+E hotkey-overlay-title="文档管理器 Filemanager" { spawn-sh "thunar || env GSK_RENDERER=gl GTK_IM_MODULE=fcitx nautilus"; }
// 另一个打开nautilus的快捷键主要是为了在同时安装thunar和nautilus的情况下打开naultilus
Mod+Alt+E hotkey-overlay-title=null {spawn "env" "GSK_RENDERER=gl" "GTK_IM_MODULE=fcitx" "nautilus" "--new-window";}
Mod+Z hotkey-overlay-title="程序菜单 Applauncher" { spawn "fuzzel"; }
// 锁屏
Mod+Alt+L hotkey-overlay-title="锁屏 Lock screen" { spawn-sh "hyprlock -c ~/.config/niri/hyprlock.conf"; }
// 这是我自己的剪贴板程序对应aur包shorinclip-git
Mod+Alt+V hotkey-overlay-title="剪贴板 Clipboard" {spawn-sh "footclient -a shorinclip shorinclip";}
// 调节音量
XF86AudioRaiseVolume allow-when-locked=true { spawn-sh "swayosd-client --output-volume +5||wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05+"; }
XF86AudioLowerVolume allow-when-locked=true { spawn-sh "swayosd-client --output-volume -5||wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.05-"; }
XF86AudioMute allow-when-locked=true { spawn-sh "swayosd-client --output-volume mute-toggle||wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"; }
XF86AudioMicMute allow-when-locked=true { spawn-sh "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"; }
// 调节屏幕亮度
XF86MonBrightnessUp allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "+5%"; }
XF86MonBrightnessDown allow-when-locked=true { spawn "brightnessctl" "--class=backlight" "set" "5%-"; }
// 切换overview总览
Mod+O hotkey-overlay-title="切换总览界面 toggle overview" repeat=false { toggle-overview; }
Mod+G repeat=false { toggle-overview; }
// 关闭聚焦窗口
Mod+Q hotkey-overlay-title="关闭聚焦窗口 Close focus window" repeat=false { close-window; }
Alt+F4 hotkey-overlay-title=null repeat=false { close-window; }
// mod+鼠标中键 关闭窗口
Mod+MouseMiddle { close-window; }
// 下面的快捷键看着很多很复杂,其实并不难记。
// 记住三组方向键wasd、hjkl和上下左右箭头
// 总的来说
// super+方向键就是切换聚焦再加上ctrl就是移动窗口
// super+a/d 比较特殊不是切换聚焦而是左右合并colume相当于左右移动窗口
// super+shift就是跨显示器加上ctrl就是移动窗口
// 切换聚焦
// super+方向键
Mod+Left hotkey-overlay-title=null { focus-column-left; }
Mod+Down { focus-window-down; }
Mod+Up { focus-window-up; }
Mod+Right { focus-column-right; }
// super+vim key
Mod+H { focus-column-left; }
Mod+J { focus-window-down; }
Mod+K { focus-window-up; }
Mod+L { focus-column-right; }
// 移动colume
// super+ctrl+方向键
Mod+Ctrl+Left hotkey-overlay-title=null { move-column-left; }
Mod+Ctrl+Down { move-window-down; }
Mod+Ctrl+Up { move-window-up; }
Mod+Ctrl+Right hotkey-overlay-title=null { move-column-right; }
// super+ctrl+vimkey
Mod+Ctrl+H { move-column-left; }
Mod+Ctrl+J { move-window-down; }
Mod+Ctrl+K { move-window-up; }
Mod+Ctrl+L { move-column-right; }
// super+ctrl+a/d 向左/右移动列
Mod+Ctrl+A { move-column-left; }
Mod+Ctrl+D { move-column-right; }
// Alternative commands that move across workspaces when reaching
// the first or last window in a column.
// Mod+J { focus-window-or-workspace-down; }
// Mod+K { focus-window-or-workspace-up; }
// Mod+Ctrl+J { move-window-down-or-to-workspace-down; }
// Mod+Ctrl+K { move-window-up-or-to-workspace-up; }
// 切换到第一个colume
Mod+Home { focus-column-first; }
// 切换到最后一个colume
Mod+End { focus-column-last; }
// 移动colume到第一个
Mod+Ctrl+Home { move-column-to-first; }
// 移动colume到最后一个
Mod+Ctrl+End { move-column-to-last; }
// 切换显示器聚焦
// mod+shift+方向键
Mod+Shift+Left { focus-monitor-left; }
Mod+Shift+Down { focus-monitor-down; }
Mod+Shift+Up { focus-monitor-up; }
Mod+Shift+Right { focus-monitor-right; }
// mod+shift+vimkey
Mod+Shift+H { focus-monitor-left; }
Mod+Shift+J { focus-monitor-down; }
Mod+Shift+K { focus-monitor-up; }
Mod+Shift+L { focus-monitor-right; }
// 跨显示器移动colume
Mod+Shift+Ctrl+Left { move-column-to-monitor-left; }
Mod+Shift+Ctrl+Down { move-column-to-monitor-down; }
Mod+Shift+Ctrl+Up { move-column-to-monitor-up; }
Mod+Shift+Ctrl+Right { move-column-to-monitor-right; }
Mod+Shift+Ctrl+H { move-column-to-monitor-left; }
Mod+Shift+Ctrl+J { move-column-to-monitor-down; }
Mod+Shift+Ctrl+K { move-column-to-monitor-up; }
Mod+Shift+Ctrl+L { move-column-to-monitor-right; }
Mod+Shift+Ctrl+A { move-column-to-monitor-left; }
Mod+Shift+Ctrl+S { move-column-to-monitor-down; }
Mod+Shift+Ctrl+W { move-column-to-monitor-up; }
Mod+Shift+Ctrl+D { move-column-to-monitor-right; }
// Alternatively, there are commands to move just a single window:
// Mod+Shift+Ctrl+Left { move-window-to-monitor-left; }
// ...
// And you can also move a whole workspace to another monitor:
//移动整个工作区
// mod+shift跨显示器alt代表移动整个工作区再加上三组方向键
Mod+Shift+Alt+W { move-workspace-to-monitor-up; }
Mod+Shift+Alt+S { move-workspace-to-monitor-down; }
Mod+Shift+Alt+D { move-workspace-to-monitor-right; }
Mod+Shift+Alt+A { move-workspace-to-monitor-left; }
Mod+Shift+Alt+K { move-workspace-to-monitor-up; }
Mod+Shift+Alt+J { move-workspace-to-monitor-down; }
Mod+Shift+Alt+L { move-workspace-to-monitor-right; }
Mod+Shift+Alt+H { move-workspace-to-monitor-left; }
Mod+Shift+Alt+Up { move-workspace-to-monitor-up; }
Mod+Shift+Alt+Down { move-workspace-to-monitor-down; }
Mod+Shift+Alt+Right { move-workspace-to-monitor-right; }
Mod+Shift+Alt+Left { move-workspace-to-monitor-left; }
// 上下切换工作区
Mod+Page_Down hotkey-overlay-title=null { focus-workspace-down; }
Mod+Page_Up hotkey-overlay-title=null { focus-workspace-up; }
Mod+U { focus-workspace-down; }
Mod+I { focus-workspace-up; }
// 上下移动窗口到其他工作区
Mod+Ctrl+Page_Down hotkey-overlay-title=null { move-column-to-workspace-down; }
Mod+Ctrl+Page_Up hotkey-overlay-title=null { move-column-to-workspace-up; }
Mod+Ctrl+U { move-column-to-workspace-down; }
Mod+Ctrl+I { move-column-to-workspace-up; }
// You can bind mouse wheel scroll ticks using the following syntax.
// These binds will change direction based on the natural-scroll setting.
//
// To avoid scrolling through workspaces really fast, you can use
// the cooldown-ms property. The bind will be rate-limited to this value.
// You can set a cooldown on any bind, but it's most useful for the wheel.
// mod+shitf+滚轮上下切换工作区
Mod+Shift+WheelScrollDown hotkey-overlay-title="切换工作区 Change workspaces" cooldown-ms=150 { focus-workspace-down; }
Mod+Shift+WheelScrollUp cooldown-ms=150 { focus-workspace-up; }
//再加上ctrl移动窗口
Mod+Ctrl+Shift+WheelScrollDown cooldown-ms=150 { move-column-to-workspace-down; }
Mod+Ctrl+Shift+WheelScrollUp cooldown-ms=150 { move-column-to-workspace-up; }
// 如果滚轮支持左右的话这里可以设置切换聚焦和移动窗口
//Mod+WheelScrollRight { focus-column-right; }
//Mod+WheelScrollLeft { focus-column-left; }
//Mod+Ctrl+WheelScrollRight { move-column-right; }
//Mod+Ctrl+WheelScrollLeft { move-column-left; }
// Usually scrolling up and down with Shift in applications results in
// horizontal scrolling; these binds replicate that.
// mod+滚轮上下 左右切换聚焦
Mod+WheelScrollDown hotkey-overlay-title="滚轮切换聚焦 Change focus with wheel" { focus-column-right; }
Mod+WheelScrollUp { focus-column-left; }
// 再加上ctrl移动colume
Mod+Ctrl+WheelScrollDown { move-column-right; }
Mod+Ctrl+WheelScrollUp { move-column-left; }
// Similarly, you can bind touchpad scroll "ticks".
// Touchpad scrolling is continuous, so for these binds it is split into
// discrete intervals.
// These binds are also affected by touchpad's natural-scroll, so these
// example binds are "inverted", since we have natural-scroll enabled for
// touchpads by default.
// Mod+TouchpadScrollDown { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.02+"; }
// Mod+TouchpadScrollUp { spawn-sh "wpctl set-volume @DEFAULT_AUDIO_SINK@ 0.02-"; }
// You can refer to workspaces by index. However, keep in mind that
// niri is a dynamic workspace system, so these commands are kind of
// "best effort". Trying to refer to a workspace index bigger than
// the current workspace count will instead refer to the bottommost
// (empty) workspace.
//
// For example, with 2 workspaces + 1 empty, indices 3, 4, 5 and so on
// will all refer to the 3rd workspace.
// mod+数字切换工作区
Mod+1 { focus-workspace 1; }
Mod+2 { focus-workspace 2; }
Mod+3 { focus-workspace 3; }
Mod+4 { focus-workspace 4; }
Mod+5 { focus-workspace 5; }
Mod+6 { focus-workspace 6; }
Mod+7 { focus-workspace 7; }
Mod+8 { focus-workspace 8; }
Mod+9 { focus-workspace 9; }
// 再加上ctrl移动colume
Mod+Ctrl+1 { move-column-to-workspace 1; }
Mod+Ctrl+2 { move-column-to-workspace 2; }
Mod+Ctrl+3 { move-column-to-workspace 3; }
Mod+Ctrl+4 { move-column-to-workspace 4; }
Mod+Ctrl+5 { move-column-to-workspace 5; }
Mod+Ctrl+6 { move-column-to-workspace 6; }
Mod+Ctrl+7 { move-column-to-workspace 7; }
Mod+Ctrl+8 { move-column-to-workspace 8; }
Mod+Ctrl+9 { move-column-to-workspace 9; }
// Alternatively, there are commands to move just a single window:
// Mod+Ctrl+1 { move-window-to-workspace 1; }
// Switches focus between the current and the previous workspace.
//Mod+Tab { focus-workspace-previous; }
// The following binds move the focused window in and out of a column.
// If the window is alone, they will consume it into the nearby column to the side.
// If the window is already in a column, they will expel it out.
// mod+左右方括号 移动窗口不是移动colume是允许移动到另一个colume的窗口移动
Mod+BracketLeft { consume-or-expel-window-left; }
Mod+BracketRight { consume-or-expel-window-right; }
// mod+A/D 同效果
Mod+A hotkey-overlay-title="向左移动窗口 Move window to left between columes" { consume-or-expel-window-left; }
Mod+D hotkey-overlay-title="向右移动窗口 Move window to right between columes" { consume-or-expel-window-right; }
// mod+S/W 上下切换窗口
Mod+S { move-window-down; }
Mod+W { move-window-up; }
// mod+逗号/句号 把窗口合并或者踢出当前的colume
Mod+Comma { consume-window-into-column; }
Mod+Period { expel-window-from-column; }
// mod+shift+A/D 同效果
Mod+Shift+A { consume-window-into-column; }
Mod+Shift+D { expel-window-from-column; }
// 开启colume的标签页模式同一个colume中的窗口会以类似浏览器标签页的形式堆叠
Mod+Shift+X { toggle-column-tabbed-display; }
Mod+X { toggle-column-tabbed-display; }
// mod+鼠标侧键 上下切换聚焦
Mod+MouseForward { focus-window-up; }
Mod+MouseBack { focus-window-down; }
// 按照预设切换窗口宽度
Mod+R hotkey-overlay-title="按预设切换宽度 Switch width " { switch-preset-column-width; }
// Cycling through the presets in reverse order is also possible.
// Mod+R { switch-preset-column-width-back; }
// 按照预设切换窗口高度
Mod+Shift+R { switch-preset-window-height; }
// 重置窗口高度
Mod+Ctrl+R { reset-window-height; }
Mod+F hotkey-overlay-title="最大化 maximize" { maximize-column; }
Mod+Alt+F hotkey-overlay-title="全屏 fullscreen" { fullscreen-window; }
// Expand the focused column to space not taken up by other fully visible columns.
// Makes the column "fill the rest of the space".
// 没什么用。增加窗口宽度占满空闲空间
Mod+Ctrl+F { expand-column-to-available-width; }
// 居中当前聚焦的colume
Mod+C { center-column; }
// Center all fully visible columns on screen.
// 没什么用
Mod+Ctrl+C { center-visible-columns; }
// Finer width adjustments.
// This command can also:
// * set width in pixels: "1000"
// * adjust width in pixels: "-5" or "+5"
// * set width as a percentage of screen width: "25%"
// * adjust width as a percentage of screen width: "-10%" or "+10%"
// Pixel sizes use logical, or scaled, pixels. I.e. on an output with scale 2.0,
// set-column-width "100" will make the column occupy 200 physical screen pixels.
// mod+加减号调整窗口宽度
Mod+Minus { set-column-width "-5%"; }
Mod+Equal { set-column-width "+5%"; }
// Finer height adjustments when in column with other windows.
// mod+shift+加减号调整窗口高度
Mod+Shift+Minus { set-window-height "-5%"; }
Mod+Shift+Equal { set-window-height "+5%"; }
// Move the focused window between the floating and the tiling layout.
// 切换浮动模式
Mod+V hotkey-overlay-title="切换浮动 Toggle floating" { toggle-window-floating; }
// 在浮动模式和非浮动模式之间切换聚焦
Mod+Shift+V hotkey-overlay-title=null { switch-focus-between-floating-and-tiling; }
Mod+N hotkey-overlay-title="切换浮动聚焦 Change focus to floating" { switch-focus-between-floating-and-tiling; }
Alt+grave hotkey-overlay-title=null { switch-focus-between-floating-and-tiling; }
Mod+Alt+N hotkey-overlay-title=null { switch-focus-between-floating-and-tiling; }
// Toggle tabbed column display mode.
// Windows in this column will appear as vertical tabs,
// rather than stacked on top of each other.
// Actions to switch layouts.
// Note: if you uncomment these, make sure you do NOT have
// a matching layout switch hotkey configured in xkb options above.
// Having both at once on the same hotkey will break the switching,
// since it will switch twice upon pressing the hotkey (once by xkb, once by niri).
//Mod+Shift+X { switch-layout "next"; }
//Mod+Shift+Z { switch-layout "prev"; }
// 截图相关
// 截图前创建一个用来触发截图音效进程的token
Mod+Alt+A hotkey-overlay-title="选取区域截图 Select screenshot" {spawn-sh "niri msg action screenshot --show-pointer false && pkill -f -USR1 screenshot-sound.sh";}
Mod+Alt+Ctrl+A hotkey-overlay-title="截取聚焦窗口 Focus-window screenshot" { spawn-sh "niri msg action screenshot-window && pkill -f -USR1 screenshot-sound.sh"; }
Mod+Alt+Ctrl+Shift+A hotkey-overlay-title="截取显示器 Monitor screenshot" { spawn-sh "niri msg action screenshot-screen --show-pointer false && pkill -f -USR1 screenshot-sound.sh"; }
Print hotkey-overlay-title=null {spawn-sh "niri msg action screenshot --show-pointer false && pkill -f -USR1 screenshot-sound.sh";}
Ctrl+Print hotkey-overlay-title=null { spawn-sh "niri msg action screenshot-window --show-pointer false && pkill -f -USR1 screenshot-sound.sh"; }
Shift+Print hotkey-overlay-title=null { spawn-sh "niri msg action screenshot-screen --show-pointer false && pkill -f -USR1 screenshot-sound.sh"; }
//Mod+Shift+S { spawn "~/.config/niri/scripts/satty-screenshot.sh";}
Mod+Shift+S hotkey-overlay-title="截图后按下此键进行编辑 Edit the image after screenshot" { spawn-sh "wl-paste | satty -f -";}
// Applications such as remote-desktop clients and software KVM switches may
// request that niri stops processing the keyboard shortcuts defined here
// so they may, for example, forward the key presses as-is to a remote machine.
// It's a good idea to bind an escape hatch to toggle the inhibitor,
// so a buggy application can't hold your session hostage.
//
// The allow-inhibiting=false property can be applied to other binds as well,
// which ensures niri always processes them, even when an inhibitor is active.
Mod+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; }
// The quit action will show a confirmation dialog to avoid accidental exits.
Mod+Shift+Ctrl+Q hotkey-overlay-title=null { spawn "wlogout"; }
Mod+Shift+E hotkey-overlay-title="退出niri Quit niri" { quit; }
// Powers off the monitors. To turn them back on, do any input like
// moving the mouse or pressing any other key.
Mod+Alt+P hotkey-overlay-title="休眠 Turn off monitors" { spawn-sh "niri msg action power-off-monitors && hyprlock && systemctl suspend"; }
}

View File

@ -0,0 +1,210 @@
// ██████ ██ ██ ██████ ███████ ██ ███ ██
// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
// ███████ ███████ ██ ██ ██████ ██ ██ ██ ██
// ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
// ██████ ██ ██ ██████ ██ ██ ██ ██ ████
// 自25.11版本开始niri支持配置文件拆分所有include都代表后面的文件是拆分出去的不包含在这个文件内
// binds里设置了快捷键rule是窗口和layer规则output是显示器如果你用我的脚本安装output里会是空的配置方法可以看文档
include "binds.kdl"
include "rule.kdl"
include "output.kdl"
include "layout.kdl"
// 截图保存位置
screenshot-path "~/Pictures/Screenshots/Niri-screenshots/%Y-%m-%d %H-%M-%S.png"
// 环境变量
environment {
//LC_CTYPE "zh_CN.UTF-8" 会导致输入法出现漏字
//LC_MESSAGES "zh_CN.UTF-8" 让系统全局使用英文,仅主要界面为英文时使用这个环境变量
// 设置界面语言
LANG "zh_CN.UTF-8"
LC_CTYPE "en_US.UTF-8" //这一项可以解决漏字问题但是也许会导致steam之类的x11应用无法使用中文输入法
// 输入法环境变量
XMODIFIERS "@im=fcitx"
// qt主题
QT_QPA_PLATFORMTHEME "gtk3"
QT_QPA_PLATFORMTHEME_QT6 "gtk3"
// 解决quickshell图标主题缺失问题
QS_ICON_THEME "Adwaita"
// GTK软件使用的渲染器可以解决n卡双显卡导致的GTK应用启动缓慢问题AMD或Intel单显卡不需要这行设置可以注释掉
GSK_RENDERER "gl"
// 默认文本编辑器
EDITOR "vim"
}
// 光标配置
cursor {
// 主题,存放路径在~/.local/share/icons
xcursor-theme "breeze_cursors"
// 大小
xcursor-size 30
// 闲置多少毫秒自动隐藏光标
hide-after-inactive-ms 15000
}
// 带缩略图的alt+tab切换窗口功能但是我设置的是super+tab更符合逻辑
recent-windows {
// 取消//off的注释可以禁用
// off
debounce-ms 750
open-delay-ms 150
highlight {
active-color "#999999ff"
urgent-color "#ff9999ff"
// 缩略图背景内间距
padding 30
// 缩略图的背景圆角
corner-radius 12
}
//设置缩略图大小
previews {
max-height 480
max-scale 0.2
}
binds {
// scope可以设置显示的窗口是当前工作区的、还是当前显示器的、或者显示全部窗口
Mod+Tab { next-window scope="workspace"; }
Mod+Shift+Tab { previous-window scope="workspace"; }
// grave是波浪键显示当前应用的所有窗口
Mod+grave { next-window filter="app-id"; }
Mod+Shift+grave { previous-window filter="app-id"; }
}
}
input {
keyboard {
xkb {
// You can set rules, model, layout, variant and options.
// For more information, see xkeyboard-config(7).
// For example:
// layout "us,ru"
// options "grp:win_space_toggle,compose:ralt,ctrl:nocaps"
// If this section is empty, niri will fetch xkb settings
// from org.freedesktop.locale1. You can control these using
// localectl set-x11-keymap.
}
// Enable numlock on startup, omitting this setting disables it.
//numlock
}
// Next sections include libinput settings.
// Omitting settings disables them, or leaves them at their default values.
// All commented-out settings here are examples, not defaults.
touchpad {
// off
tap
// dwt
// dwtp
// drag false
// drag-lock
// nautural-scroll可以翻转触摸板滚动的方向
natural-scroll
//accel-speed -0.5
// accel-profile "flat"
// scroll-method "two-finger"
// disabled-on-external-mouse
}
mouse {
// off
// natural-scroll
// 鼠标速度
accel-speed -0.15
// 禁用鼠标加速
accel-profile "flat"
// scroll-method "no-scroll"
//speed of scroll,like:
//scroll-factor horizontal=2.0 vertical=-5.0
}
trackpoint {
// off
// natural-scroll
// accel-speed 0.2
// accel-profile "flat"
// scroll-method "on-button-down"
// scroll-button 273
// scroll-button-lock
// middle-emulation
}
// Uncomment this to make the mouse warp to the center of newly focused windows.
//warp-mouse-to-focus
// Focus windows and outputs automatically when moving the mouse into them.
// Setting max-scroll-amount="0%" makes it work only on windows already fully on screen.
//focus-follows-mouse max-scroll-amount="50%"
}
//blur
//blur {
// off
//passes 3
//offset 2
//noise 0.02
//saturation 1.5
//}
overview {
// 关闭overview里的工作区阴影配合layout里面的透明工作区背景可以做到让工作区和overview共用同一个背景。在意内存占用的可以把waypaper的后端改成swaybg,然后关闭桌面自动模糊功能取消swww自动启动能节省250MB左右内存
workspace-shadow {
//off
}
//缩放
zoom 0.5
}
// Add lines like this to spawn processes at startup.
// Note that running niri as a session supports xdg-desktop-autostart,
// which may be more convenient to use.
// See the binds section below for more ipawn examples.
// 询问管理员权限功能(身份验证)
spawn-at-startup "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1"
// 屏幕分享、录屏相关的环境设置,如果屏幕分享出异常的话可以开启
spawn-sh-at-startup "dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=niri & /usr/lib/xdg-desktop-portal-gnome"
// GNOME tracker修复
spawn-sh-at-startup "systemctl --user set-environment XDG_SESSION_CLASS=user"
spawn-at-startup "foot" "-s"
// 通知程序
spawn-at-startup "mako"
// 任务栏
spawn-at-startup "waybar"
// 输入法
spawn-at-startup "fcitx5"
// 剪贴板守护进程
//cliphist
spawn-at-startup "wl-paste" "--watch" "cliphist" "store"
// wayland <--> x11 剪贴板同步 这个包是我自己推的clipsync-git
//spawn-at-startup "systemctl" "--user" "start" "clipsync"
// 闲置时自动熄屏锁屏睡眠的脚本说实话这东西毫无用处super+alt+P可以熄屏休眠
// spawn-at-startup "~/.config/niri/scripts/swayidle.sh"
// 自动开启护眼模式,经纬度设置位置
spawn-at-startup "~/.config/niri/scripts/toggle-wlsunset"
// 截图音效的守护进程
spawn-at-startup "~/.config/niri/scripts/screenshot-sound.sh"
// 允许root通过用户的xwayland打开窗口
spawn-at-startup "xhost" "+si:localuser:root"
// 取消启动niri时自动开启快捷键教程
hotkey-overlay {
// Uncomment this line to disable the "Important Hotkeys" pop-up at startup.
skip-at-startup
}
// 隐藏窗口标题栏
prefer-no-csd

View File

@ -0,0 +1,101 @@
$background = rgba(131318ff)
$error = rgba(ffb4abff)
$error_container = rgba(93000aff)
$inverse_on_surface = rgba(303036ff)
$inverse_primary = rgba(555a92ff)
$inverse_surface = rgba(e4e1e9ff)
$on_background = rgba(e4e1e9ff)
$on_error = rgba(690005ff)
$on_error_container = rgba(ffdad6ff)
$on_primary = rgba(262b60ff)
$on_primary_container = rgba(e0e0ffff)
$on_primary_fixed = rgba(10144bff)
$on_primary_fixed_variant = rgba(3d4279ff)
$on_secondary = rgba(2e2f42ff)
$on_secondary_container = rgba(e1e0f9ff)
$on_secondary_fixed = rgba(191a2cff)
$on_secondary_fixed_variant = rgba(444559ff)
$on_surface = rgba(e4e1e9ff)
$on_surface_variant = rgba(c7c5d0ff)
$on_tertiary = rgba(45263cff)
$on_tertiary_container = rgba(ffd8eeff)
$on_tertiary_fixed = rgba(2e1126ff)
$on_tertiary_fixed_variant = rgba(5e3c53ff)
$outline = rgba(91909aff)
$outline_variant = rgba(46464fff)
$primary = rgba(bec2ffff)
$primary_container = rgba(3d4279ff)
$primary_fixed = rgba(e0e0ffff)
$primary_fixed_dim = rgba(bec2ffff)
$scrim = rgba(000000ff)
$secondary = rgba(c5c4ddff)
$secondary_container = rgba(444559ff)
$secondary_fixed = rgba(e1e0f9ff)
$secondary_fixed_dim = rgba(c5c4ddff)
$shadow = rgba(000000ff)
$source_color = rgba(5a61b1ff)
$surface = rgba(131318ff)
$surface_bright = rgba(39393fff)
$surface_container = rgba(1f1f25ff)
$surface_container_high = rgba(2a292fff)
$surface_container_highest = rgba(34343aff)
$surface_container_low = rgba(1b1b21ff)
$surface_container_lowest = rgba(0e0e13ff)
$surface_dim = rgba(131318ff)
$surface_tint = rgba(bec2ffff)
$surface_variant = rgba(46464fff)
$tertiary = rgba(e7b9d5ff)
$tertiary_container = rgba(5e3c53ff)
$tertiary_fixed = rgba(ffd8eeff)
$tertiary_fixed_dim = rgba(e7b9d5ff)

View File

@ -0,0 +1,148 @@
# 引入 Matugen 生成的颜色文件
# 确保 Matugen 已经运行并生成了此文件,否则变量无法解析
source = ~/.config/niri/hyprlock-colors.conf
# 定义字体变量,方便统一修改
$font = JetBrains Maple Mono
$font_clock = JetBrains Maple Mono
general {
hide_cursor = false # 锁屏时不隐藏鼠标光标
ignore_empty_input = true # 开启后,输入框为空时按回车不会显示“验证失败”,而是直接忽略
}
animations {
enabled = true
# 贝塞尔曲线定义 (控制动画速度变化)
bezier = linear, 1, 1, 0, 0
# 动画定义: 动画名, 开关(1/0), 持续时间, 曲线
animation = fadeIn, 1, 3, linear # 淡入动画
animation = fadeOut, 1, 5, linear # 淡出动画
animation = inputFieldDots, 1, 2, linear # 输入密码时圆点的跳动动画
}
background {
monitor = # 留空表示应用到所有显示器
path = screenshot # 使用当前屏幕截图作为背景
color = $surface # 如果截图加载失败,使用的默认背景色
# === 高斯模糊与质感设置 ===
# 这些参数共同营造出“磨砂玻璃”的高级感
blur_size = 5 # 模糊半径
blur_passes = 4 # 模糊迭代次数 (越高越平滑,但消耗性能)
noise = 0.01 # 添加轻微噪点,防止色带(banding)并增加胶片感
contrast = 1.3000 # 提高对比度,让文字更清晰
brightness = 0.8000 # 降低亮度,避免背景太亮抢眼
vibrancy = 0.2100 # 增加色彩鲜艳度
vibrancy_darkness = 0.0
}
# === 视觉重心上移 (Visual Shift Up) ===
# 策略:保持上一版完美的紧凑间距,将整体坐标向上平移约 20%
# 这样时间组件会占据屏幕的上三分之一处,留下开阔的中下部空间。
# Hours (小时)
label {
monitor =
# cmd[update:1000]: 每 1000ms (1秒) 更新一次
# <b><big>: Pango 标记语法,用于加粗和放大字体
text = cmd[update:1000] echo "<b><big> $(date +"%H") </big></b>"
color = $primary # 使用主色调
font_size = 130
font_family = $font_clock
# 文字阴影设置,增加立体感
shadow_passes = 3 # 阴影迭代次数
shadow_size = 4 # 阴影扩散大小
# 上移至 29% (垂直方向)
position = 0, 29%
halign = center # 水平居中
valign = center # 垂直居中
}
# Minutes (分钟)
label {
monitor =
text = cmd[update:1000] echo "<b><big> $(date +"%M") </big></b>"
color = $primary
font_size = 130
font_family = $font_clock
shadow_passes = 3
shadow_size = 4
# 保持 13% 的黄金间距 -> 19% (相对于小时的位置)
# 这里的 16% 是绝对位置
position = 0, 16%
halign = center
valign = center
}
# === 日期信息 (Date Info) ===
# Today (星期几)
label {
monitor =
# cmd[update:18000000]: 更新频率很低,因为星期几很久才变一次,节省资源
text = cmd[update:18000000] echo "<b><big> "$(date +'%A')" </big></b>"
color = $secondary # 使用次级颜色,建立视觉层级
font_size = 28
font_family = $font
# 紧随分钟下方 -> 7%
position = 0, 7%
halign = center
valign = center
}
# Week (日期)
label {
monitor =
text = cmd[update:18000000] echo "<b> "$(date +'%b %d')" </b>"
color = $secondary
font_size = 18
font_family = $font
# 收尾 -> 4%
position = 0, 4%
halign = center
valign = center
}
# === 底部交互区 (Interaction Area) ===
# Input Field (输入框)
input-field {
monitor =
size = 9%, 3.1% # 使用百分比宽高,适配不同分辨率的屏幕
outline_thickness = 2 # 边框粗细
# 密码掩码圆点设置
dots_size = 0.26 # 圆点相对于输入框高度的大小
dots_spacing = 0.64 # 圆点之间的间距
dots_center = true # 圆点垂直居中
dots_rounding = -1 # -1 表示完美的圆形
rounding = 12 # 输入框圆角半径
# 颜色设置 (支持渐变)
# 这里的 outer_color 使用了渐变色: 主色 -> 第三色 -> 主色
outer_color = $primary $tertiary $primary
inner_color = $surface_container # 输入框背景色
font_color = $on_surface # 输入文字颜色
check_color = $secondary # 验证中颜色
fail_color = $error # 验证失败颜色
fade_on_empty = false # 即使没有输入内容,输入框也保持显示 (不消失)
placeholder_text = <i>Password...</i> # 占位符提示文字 (斜体)
# 保持在底部 10%,与上方的时间形成极大的张力
position = 0, 10%
halign = center # 水平居中
valign = bottom # 垂直对齐到底部
}

View File

@ -0,0 +1,161 @@
layout {
//设置工作区背景颜色
//background-color "transparent"
// Set gaps around windows in logical pixels.
// 窗口和窗口之间的间距
gaps 12
//empty-workspace-above-first
// When to center a column when changing focus, options are:
// - "never", default behavior, focusing an off-screen column will keep at the left
// or right edge of the screen.
// - "always", the focused column will always be centered.
// - "on-overflow", focusing a column will center it if it doesn't fit
// together with the previously focused column.
center-focused-column "never"
// You can customize the widths that "switch-preset-column-width" (Mod+R) toggles between.
// 预设窗口宽度
preset-column-widths {
// Proportion sets the width as a fraction of the output width, taking gaps into account.
// For example, you can perfectly fit four windows sized "proportion 0.25" on an output.
// The default preset widths are 1/3, 1/2 and 2/3 of the output.
proportion 0.33333
proportion 0.5
proportion 0.66667
// Fixed sets the width in logical pixels exactly.
// fixed 1920
}
// You can also customize the heights that "switch-preset-window-height" (Mod+Shift+R) toggles between.
// preset-window-heights { }
// You can change the default width of the new windows.
// 默认的窗口宽度
default-column-width { proportion 0.5; }
// If you leave the brackets empty, the windows themselves will decide their initial width.
// default-column-width {}
// By default focus ring and border are rendered as a solid background rectangle
// behind windows. That is, they will show up through semitransparent windows.
// This is because windows using client-side decorations can have an arbitrary shape.
//
// If you don't like that, you should uncomment `prefer-no-csd` below.
// Niri will draw focus ring and border *around* windows that agree to omit their
// client-side decorations.
//
// Alternatively, you can override it with a window rule called
// `draw-border-with-background`.
// You can change how the focus ring looks.
// 聚焦窗口边框这个的颜色设置在我include进来的colors.kdl里
focus-ring {
// Uncomment this line to disable the focus ring.
// off
// How many logical pixels the ring extends out from the windows.
width 3
// Colors can be set in a variety of ways:
// - CSS named colors: "red"
// - RGB hex: "#rgb", "#rgba", "#rrggbb", "#rrggbbaa"
// - CSS-like notation: "rgb(255, 127, 0)", rgba(), hsl() and a few others.
// Color of the ring on the active monitor.
//active-color "@primary"
//active-color "#00000000"
// Color of the ring on inactive monitors.
//
// The focus ring only draws around the active window, so the only place
// where you can see its inactive-color is on other monitors.
//inactive-color "#505050"
// You can also use gradients. They take precedence over solid colors.
// Gradients are rendered the same as CSS linear-gradient(angle, from, to).
// The angle is the same as in linear-gradient, and is optional,
// defaulting to 180 (top-to-bottom gradient).
// You can use any CSS linear-gradient tool on the web to set these up.
// Changing the color space is also supported, check the wiki for more info.
//
// active-gradient from="#80c8ff" to="#c7ff7f" angle=45
// You can also color the gradient relative to the entire view
// of the workspace, rather than relative to just the window itself.
// To do that, set relative-to="workspace-view".
//
//inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
}
// You can also add a border. It's similar to the focus ring, but always visible.
// 窗口边框
border {
// The settings are the same as for the focus ring.
// If you enable the border, you probably want to disable the focus ring.
off
width 4
active-color "#ffc87f"
inactive-color "#505050"
// Color of the border around windows that request your attention.
urgent-color "#9b0000"
// Gradients can use a few different interpolation color spaces.
// For example, this is a pastel rainbow gradient via in="oklch longer hue".
//
// active-gradient from="#e5989b" to="#ffb4a2" angle=45 relative-to="workspace-view" in="oklch longer hue"
// inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
}
// You can enable drop shadows for windows.
// 阴影
shadow {
// Uncomment the next line to enable shadows.
on
// By default, the shadow draws only around its window, and not behind it.
// Uncomment this setting to make the shadow draw behind its window.
//
// Note that niri has no way of knowing about the CSD window corner
// radius. It has to assume that windows have square corners, leading to
// shadow artifacts inside the CSD rounded corners. This setting fixes
// those artifacts.
//
// However, instead you may want to set prefer-no-csd and/or
// geometry-corner-radius. Then, niri will know the corner radius and
// draw the shadow correctly, without having to draw it behind the
// window. These will also remove client-side shadows if the window
// draws any.
//
//draw-behind-window true
// You can change how shadows look. The values below are in logical
// pixels and match the CSS box-shadow properties.
// Softness controls the shadow blur radius.
softness 20
// Spread expands the shadow.
spread 2
// Offset moves the shadow relative to the window.
offset x=-4 y=-4
// You can also change the shadow color and opacity.
color "rgba(0, 0, 0, 0.7)"
}
// Struts shrink the area occupied by windows, similarly to layer-shell panels.
// You can think of them as a kind of outer gaps. They are set in logical pixels.
// Left and right struts will cause the next window to the side to always be visible.
// Top and bottom struts will simply add outer gaps in addition to the area occupied by
// layer-shell panels and regular gaps.
//窗口距离屏幕边缘的距离
struts {
//left 64
// right 64
// top 64
// bottom 64
}
}

View File

@ -0,0 +1,16 @@
output "eDP-1"{
// off
mode "2560x1440@165"
scale 1.3
position x=0 y=0
}
output "DP-2"{
//主要显示器DP-2
mode "2560x1440@180"
scale 1
position x=0 y=0
focus-at-startup
}

View File

@ -0,0 +1,175 @@
// Window rules let you adjust behavior for individual windows.
// Find more information on the wiki:
// https://yalter.github.io/niri/Configuration:-Window-Rules
// 放进overview里的壁纸程序
layer-rule{
match namespace="hyprpaper"
match namespace="wallpaper"
match namespace="awww-daemon"
match namespace="swww-daemonoverview"
place-within-backdrop true
}
// 全局窗口规则
window-rule {
// 这一行规则可以让niri变成传统桌面那样的堆叠式桌面。
//open-floating true
// 圆角
//geometry-corner-radius 8
// 去掉超出圆角的窗口内容
//clip-to-geometry true
// 全局透明度
//opacity 0.98
// 禁止边框画到背景里
draw-border-with-background false
}
// niri-siderbar需要的全局窗口规则
window-rule {
match is-floating=true
min-width 100
min-height 100
}
// 以浮动模式打开imv一个轻量化图片预览程序且不自动聚焦
window-rule {
match app-id="imv"
open-focused false
open-floating true
}
//shorinclip剪贴板TUI
window-rule{
match app-id="shorinclip"
default-column-width { fixed 625; }
default-window-height { fixed 700; }
//min-height 800
open-floating true
default-floating-position x=0 y=18 relative-to="top"
}
// 以浮动模式打开的软件
window-rule {
// This app-id regular expression will work for both:
// - host Firefox (app-id is "firefox")
// - Flatpak Firefox (app-id is "org.mozilla.firefox")
match app-id="com.gabm.satty"
match app-id="media_info"
match app-id="video2gif"
match app-id="floating-term"
match app-id="nm-connection-editor"
match app-id="niri-quick-switch"
match app-id=r#"firefox$"# title="^Picture-in-Picture$"
match app-id="steam" title="Friends List"
match app-id="blueberry.py" title="蓝牙"
match app-id="blueman-manager"
match app-id="flameshot"
match app-id="com.github.hluk.copyq"
match app-id="be.alexandervanhee.gradia"
match app-id="org.pulseaudio.pavucontrol" title="音量控制"
match app-id="org.gnome.clocks" title="时钟"
match app-id="fcitx" title="Fcitx5 Input Window"
match app-id="org.gnome.FileRoller"
match app-id="thunar" title="文件操作进度"
match app-id="waypaper"
match app-id="clipse-gui"
match title="群聊的聊天记录"
match title="聊天记录"
match title="日历"
match title="重命名"
match app-id="btrfs-assistant"
match app-id="markpix"
match title="Steam 设置"
match title="另存为"
match app-id="better_control.py"
open-floating true
}
// waybar命令中心模块
window-rule {
match app-id="command-center"
default-column-width { fixed 1000; }
default-window-height { fixed 600; }
open-floating true
}
//快速终端和笔记
window-rule {
match app-id="notebook"
match app-id="quickterminal"
open-floating true
default-floating-position x=20 y=20 relative-to="top"
}
window-rule{
match app-id="bluetui"
match app-id="impala"
default-column-width { fixed 800; }
default-window-height { fixed 800; }
open-floating true
}
window-rule {
match app-id="clipse"
default-column-width { fixed 625; }
default-window-height { fixed 700; }
open-floating true
}
// waydroid调整
window-rule {
match title="gsr ui"
match app-id="waydroid"
open-fullscreen true
open-floating true
focus-ring{
off
}
shadow {
off
}
}
// 取消图片预览、视频播放器之类的透明度,并且以浮动模式打开
window-rule {
match title="图片查看器"
match title="画中画"
match title="图片和视频"
match title="视频播放器"
open-floating true
opacity 1.0
}
window-rule {
match app-id="mpv"
match app-id="celluloid"
opacity 1.0
}
window-rule {
// This regular expression is intentionally made as specific as possible,
// since this is the default config, and we want no false positives.
// You can get away with just app-id="wezterm" if you want.
match app-id=r#"^org\.wezfurlong\.wezterm$"#
default-column-width {}
}
/-window-rule {
// This app-id regular expression will work for both:
// - host Firefox (app-id is "firefox")
// - Flatpak Firefox (app-id is "org.mozilla.firefox")
default-floating-position x=0 y=0 relative-to="bottom-right"
open-floating true
}
// window-rule {
// // This app-id regular expression will work for both:
// // - host Firefox (app-id is "firefox")
// // - Flatpak Firefox (app-id is "org.mozilla.firefox")
// match app-id="blueman-manager" title="蓝牙设备"
// match app-id="org.pulseaudio.pavucontrol" title="音量控制"
// default-floating-position x=0 y=0 relative-to="top-right"
// open-floating true
// }
// Example: block out two password managers from screen capture.
// (This example rule is commented out with a "/-" in front.)
window-rule {
match app-id=r#"^org\.keepassxc\.KeePassXC$"#
match app-id=r#"^org\.gnome\.World\.Secrets$"#
match app-id="wechat"
block-out-from "screen-capture"
// Use this instead if you want them visible on third-party screenshot tools.
// block-out-from "screencast"
}

View File

@ -0,0 +1,58 @@
#!/usr/bin/env bash
NIRI_DIR="$HOME/.config/niri"
# === 界面尺寸设置 (在这里微调,下方的所有终端会自动应用) ===
MENU_WIDTH=90
MENU_HEIGHT=20
# 检查目录
if [[ ! -d "$NIRI_DIR" ]]; then
echo "Error: 找不到配置目录 $NIRI_DIR"
exit 1
fi
# 提取并使用 column 对齐
MENU_ITEMS=$(grep -Rh 'hotkey-overlay-title=' "$NIRI_DIR" --include="*.kdl" | \
grep -v '^[ \t]*//' | \
sed -n -E 's/^[ \t]*(.*)[ \t]+hotkey-overlay-title="([^"]+)".*/\1|\2/p' | \
sed -E 's/[ \t]*\|/\|/' | \
column -t -s '|')
if [[ -z "$MENU_ITEMS" ]]; then
echo "没有找到有效的快捷键配置。"
exit 1
fi
# Fzf 核心命令
FZF_CMD="echo \"$MENU_ITEMS\" | fzf --reverse --prompt='󰌌 快捷键: ' --info=hidden --border=none > /dev/null"
# 动态检测终端并使用对应的参数启动
if command -v kitty >/dev/null 2>&1; then
kitty --class "niri-hotkey-menu" --title "快捷键菜单" \
-o remember_window_size=no -o initial_window_width=${MENU_WIDTH}c -o initial_window_height=${MENU_HEIGHT}c \
bash -c "$FZF_CMD"
elif command -v foot >/dev/null 2>&1; then
foot --app-id "niri-hotkey-menu" --title "快捷键菜单" \
--window-size-chars=${MENU_WIDTH}x${MENU_HEIGHT} \
bash -c "$FZF_CMD"
elif command -v alacritty >/dev/null 2>&1; then
alacritty --class "niri-hotkey-menu" --title "快捷键菜单" \
-o window.dimensions.columns=${MENU_WIDTH} -o window.dimensions.lines=${MENU_HEIGHT} \
-e bash -c "$FZF_CMD"
elif command -v wezterm >/dev/null 2>&1; then
wezterm start --class "niri-hotkey-menu" -- bash -c "$FZF_CMD"
elif [[ -n "$TERMINAL" ]]; then
$TERMINAL -e bash -c "$FZF_CMD"
else
echo "Error: 未检测到支持的终端模拟器。"
if command -v fuzzel >/dev/null 2>&1; then
# Fuzzel 降级方案也会自动读取顶层变量
echo "$MENU_ITEMS" | fuzzel --dmenu -i -p "󰌌 快捷键: " -w ${MENU_WIDTH} > /dev/null
fi
fi

View File

@ -0,0 +1,152 @@
#!/usr/bin/env python3
import subprocess
import json
import sys
import shutil
import time # <--- 新增:用于等待窗口关闭生效
# ================= Configuration =================
EXCLUDE_APPS = ["fuzzel", "quick-switch", "niri-quick-switch"]
FUZZEL_ARGS = [
"--dmenu",
"--index",
"--width", "60",
"--lines", "15",
"--prompt", "Switch: ",
# 修改了这里:提示 Ctrl+L 跳转Ctrl+H 关闭
"--placeholder", "Search... [Ctrl+J/K: Select | Ctrl+L: Switch | Ctrl+H: Close]"
]
# =================================================
def run_cmd(cmd):
try:
result = subprocess.run(cmd, shell=True, capture_output=True, text=True)
if result.returncode != 0: return None
if "-j" in cmd:
return json.loads(result.stdout)
return result.stdout
except Exception: return None
def get_active_output_workspace_ids():
"""
获取当前活动显示器output上的所有工作区 ID
"""
workspaces = run_cmd("niri msg -j workspaces")
if not workspaces: return set()
# 1. 找到当前聚焦的工作区所在的显示器名称
active_output = None
for ws in workspaces:
if ws.get("is_focused"):
active_output = ws.get("output")
break
if not active_output: return set()
# 2. 收集该显示器上的所有工作区 ID
valid_ws_ids = set()
for ws in workspaces:
if ws.get("output") == active_output:
valid_ws_ids.add(ws.get("id"))
return valid_ws_ids
def get_window_sort_key(w):
# 将 workspace_id 作为第一排序优先级,确保不同工作区的窗口按组排列
ws_id = w.get("workspace_id", 0)
if w.get("is_floating"):
return (ws_id, 99999, 0, w.get("id"))
try:
layout = w.get("layout", {})
if not layout: return (ws_id, 9999, 0, w.get("id"))
pos = layout.get("pos_in_scrolling_layout")
if pos and isinstance(pos, list) and len(pos) >= 2:
return (ws_id, pos[0], pos[1], w.get("id"))
except Exception:
pass
return (ws_id, 9999, 0, w.get("id"))
def main():
if not shutil.which("fuzzel"):
print("Error: Fuzzel not found")
sys.exit(1)
# === 核心改动:开启死循环 ===
while True:
# 1. 每次循环重新获取当前显示器上的所有 Workspace ID
valid_ws_ids = get_active_output_workspace_ids()
if not valid_ws_ids: break
# 2. 每次循环都重新获取最新的窗口列表
windows = run_cmd("niri msg -j windows")
if not windows: break
current_windows = []
for w in windows:
# 判断窗口是否在允许的工作区集合内
if w.get("workspace_id") not in valid_ws_ids: continue
app_id = w.get("app_id") or ""
if app_id in EXCLUDE_APPS: continue
current_windows.append(w)
# 如果没有窗口了,直接退出
if not current_windows: break
current_windows.sort(key=get_window_sort_key)
input_str = ""
for w in current_windows:
app_id = w.get("app_id") or "Wayland"
title = w.get("title", "No Title").replace("\n", " ")
display_str = f"[{app_id}] {title}"
line = f"{display_str}\0icon\x1f{app_id}"
input_str += f"{line}\n"
try:
# 3. 启动 Fuzzel
proc = subprocess.Popen(
["fuzzel"] + FUZZEL_ARGS,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
text=True
)
stdout, _ = proc.communicate(input=input_str)
return_code = proc.returncode
raw_output = stdout.strip()
# 情况 A: 用户按 ESC 取消 -> 退出循环
if return_code not in [0, 10] or not raw_output:
break
try:
selected_idx = int(raw_output)
except ValueError:
break
if 0 <= selected_idx < len(current_windows):
target_window = current_windows[selected_idx]
target_id = target_window.get("id")
if return_code == 0:
# 动作: 切换窗口 -> 任务完成,退出循环
subprocess.run(["niri", "msg", "action", "focus-window", "--id", str(target_id)])
break
elif return_code == 10:
# 动作: 关闭窗口 -> 执行关闭,然后 CONTINUE (继续循环)
subprocess.run(["niri", "msg", "action", "close-window", "--id", str(target_id)])
# 关键:稍微等一下,让 niri 有时间处理关闭动作,
# 否则立刻刷新列表可能还会看到那个已经被杀死的窗口
time.sleep(0.1)
continue
except Exception as e:
print(f"Error: {e}")
break
if __name__ == "__main__":
main()

View File

@ -0,0 +1,72 @@
#!/bin/bash
# =================配置区域=================
SOUND="/usr/share/sounds/freedesktop/stereo/camera-shutter.oga"
# 这是一个“扳机”文件,存于内存中 (/dev/shm),读写极快
TRIGGER_FILE="/dev/shm/niri_screenshot_armed"
# 有效期:按下截图键后,多少秒内产生了图片才响?(防止你取消截图后,下次复制图片误响)
TIMEOUT_SEC=15
# =========================================
# 环境检查
if ! command -v pw-play >/dev/null; then
notify-send "错误: 未找到 pw-play"
exit 1
fi
# =========================================
# 1. 定义信号处理 (收到信号 = 上膛)
# =========================================
arm_trigger() {
# 更新文件的修改时间,或者创建它
touch "$TRIGGER_FILE"
}
# 注册信号:收到 USR1 就执行 arm_trigger
trap arm_trigger SIGUSR1
# =========================================
# 2. 启动剪贴板监听 (后台运行)
# =========================================
# 只有当剪贴板真正发生变化时,这个子进程才会醒来
wl-paste --watch bash -c "
# A. 检查是不是图片
if wl-paste --list-types 2>/dev/null | grep -q 'image/'; then
# B. 检查有没有“上膛” (文件是否存在)
if [ -f \"$TRIGGER_FILE\" ]; then
# C. 检查“上膛”是否过期 (利用文件修改时间)
# $(date +%s) - stat获取的时间
NOW=\$(date +%s)
FILE_TIME=\$(stat -c %Y \"$TRIGGER_FILE\")
DIFF=\$((NOW - FILE_TIME))
if [ \$DIFF -lt $TIMEOUT_SEC ]; then
# 조건을 满足:是图片 + 已上膛 + 没过期
pw-play \"$SOUND\" &
# D. 销毁扳机 (防止连响)
rm -f \"$TRIGGER_FILE\"
fi
fi
fi
" &
# 获取 wl-paste 的 PID以便脚本退出时杀掉它
WATCHER_PID=$!
# =========================================
# 3. 守护进程主循环 (0 CPU 占用)
# =========================================
# 这里的 trap 负责在脚本退出时清理子进程
trap "kill $WATCHER_PID; exit" INT TERM EXIT
# 写入当前 PID 方便调试 (可选)
# echo $$ > /tmp/niri-sound.pid
echo "截图音效服务已启动,等待 SIGUSR1 信号..."
# 无限睡眠,只响应信号
while true; do
sleep infinity & wait $!
done

View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
# 5分钟锁屏10分钟熄屏20分钟休眠
exec swayidle -w \
timeout 600 'hyprlock -c ~/.config/niri/hyprlock.conf &' \
timeout 900 'niri msg action power-off-monitors' \
resume 'niri msg action power-on-monitors' \
timeout 1800 'systemctl suspend'

View File

@ -0,0 +1,27 @@
#!/bin/bash
# ===============================================================
# 配置区
# ===============================================================
TEMP_LOW="5000" # 夜间/护眼色温
TEMP_HIGH="6500" # 日间/标准色温
TRANSITION="1800" # 过渡时间 (30分钟)
# 经纬度
LAT="36.5"
LONG="128.0"
# ===============================================================
# 逻辑区
# ===============================================================
if pgrep -x "wlsunset" > /dev/null; then
# 如果正在运行,则关闭
pkill wlsunset
notify-send -t 2000 -a "System" "护眼模式" "已关闭"
else
# 如果未运行,则开启
# 这里使用的是经纬度模式,如果你想用固定时间模式,
# 请把下面这行改为: wlsunset -S 07:00 -s 19:00 -t $TEMP_LOW -T $TEMP_HIGH -d $TRANSITION &
wlsunset -l $LAT -L $LONG -t $TEMP_LOW -T $TEMP_HIGH -d $TRANSITION &
notify-send -t 2000 -a "System" "护眼模式" "已开启,目标色温 ${TEMP_LOW}K"
fi