feat: add new wayland compositor - niri

This commit is contained in:
Ryan Yin
2025-08-18 21:44:18 +08:00
parent 09fbea3f77
commit 69eee64e7e
52 changed files with 333 additions and 89 deletions

View File

@@ -0,0 +1,85 @@
{
pkgs,
anyrun,
...
}:
{
programs.anyrun = {
enable = true;
config = {
plugins = with anyrun.packages.${pkgs.system}; [
applications
randr
rink
shell
symbols
translate
];
width.fraction = 0.3;
y.absolute = 15;
hidePluginInfo = true;
closeOnClick = true;
};
# custom css for anyrun, based on catppuccin-mocha
extraCss = ''
@define-color bg-col rgba(30, 30, 46, 0.7);
@define-color bg-col-light rgba(150, 220, 235, 0.7);
@define-color border-col rgba(30, 30, 46, 0.7);
@define-color selected-col rgba(150, 205, 251, 0.7);
@define-color fg-col #D9E0EE;
@define-color fg-col2 #F28FAD;
* {
transition: 200ms ease;
font-family: "Maple Mono NF CN";
font-size: 1.3rem;
}
#window {
background: transparent;
}
#plugin,
#main {
border: 3px solid @border-col;
color: @fg-col;
background-color: @bg-col;
}
/* anyrun's input window - Text */
#entry {
color: @fg-col;
background-color: @bg-col;
}
/* anyrun's output matches entries - Base */
#match {
color: @fg-col;
background: @bg-col;
}
/* anyrun's selected entry - Red */
#match:selected {
color: @fg-col2;
background: @selected-col;
}
#match {
padding: 3px;
border-radius: 16px;
}
#entry, #plugin:hover {
border-radius: 16px;
}
box#main {
background: rgba(30, 30, 46, 0.7);
border: 1px solid @border-col;
border-radius: 15px;
padding: 5px;
}
'';
};
}

View File

@@ -0,0 +1,37 @@
general {
lock_cmd = pidof swaylock || swaylock # avoid starting multiple instances
before_sleep_cmd = loginctl lock-session # lock before suspend
after_sleep_cmd = hyprctl dispatch dpms on # resume dpms after suspend
ignore_dbus_inhibit = false # whether to ignore dbus-sent idle-inhibit requests
}
listener {
timeout = 180 # 3 minutes
# List devices: brightnessctl --list
# Adjust keyboard backlight: brightnessctl -d kbd_backlight set 50%
on-timeout = brightnessctl --save --device=kbd_backlight set 0 # turn off keyboard backlight.
on-resume = brightnessctl --restore --device=kbd_backlight # turn on keyboard backlight.
}
# listener {
# timeout = 600 # 10min.
# on-timeout = brightnessctl -s set 10 # set monitor backlight to minimum, avoid 0 on OLED monitor.
# on-resume = brightnessctl -r # monitor backlight restore.
# }
listener {
timeout = 1600 # 20 minutes
on-timeout = pidof swaylock || swaylock # lock screen
on-resume = hyprctl dispatch dpms on # monitor wake up
}
listener {
timeout = 1660 # 31 minutes
on-timeout = hyprctl dispatch dpms off # screen off
on-resume = hyprctl dispatch dpms on && brightnessctl -r # monitor wake up & screen on
}
# listener {
# timeout = 1800 # 30min
# on-timeout = systemctl suspend # suspend pc
# }

View File

@@ -0,0 +1,51 @@
## Mako configuration file
# GLOBAL CONFIGURATION OPTIONS
max-history=100
sort=-time
# BINDING OPTIONS
on-button-left=dismiss
on-button-middle=none
on-button-right=dismiss-all
on-touch=dismiss
on-notify=exec mpv /usr/share/sounds/freedesktop/stereo/message.oga
# STYLE OPTIONS
font=Maple Mono NF CN
width=300
height=100
margin=10
padding=15
border-size=2
border-radius=0
icons=1
max-icon-size=48
icon-location=left
markup=1
actions=1
history=1
text-alignment=left
default-timeout=5000
ignore-timeout=0
max-visible=5
layer=overlay
anchor=top-right
background-color=#1e1e2e
text-color=#d9e0ee
border-color=#313244
progress-color=over #89b4fa
[urgency=low]
border-color=#313244
default-timeout=2000
[urgency=normal]
border-color=#313244
default-timeout=5000
[urgency=high]
border-color=#f38ba8
text-color=#f38ba8
default-timeout=0

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@@ -0,0 +1,156 @@
{
"position": "top",
"layer": "top",
"modules-left": ["custom/launcher", "temperature", "backlight", "hyprland/workspaces"],
"modules-center": ["custom/playerctl"],
"modules-right": [
"pulseaudio",
"memory",
"cpu",
"network",
"battery",
"clock",
"idle_inhibitor",
"custom/powermenu",
"tray",
],
"hyprland/workspaces": {
"format": "{icon}",
"on-click": "activate",
"format-icons": {
"1": "",
"2": "",
"3": "",
"4": "",
"5": "",
"6": "",
"7": "",
"8": "",
"9": "",
"10": "",
"focused": "",
"default": "",
},
},
"clock": {
"interval": 60,
"align": 0,
"rotate": 0,
"tooltip-format": "<big>{:%B %Y}</big>\n<tt><small>{calendar}</small></tt>",
"format": " {:%H:%M}",
"format-alt": " {:%a %b %d, %G}",
},
"cpu": {
"format": "CPU {usage}%",
"interval": 1,
"on-click-middle": "foot btop",
"on-click-right": "foot btop",
},
"memory": {
"format": "MEM {percentage}%",
"interval": 1,
"states": {
"warning": 85,
},
},
"custom/launcher": {
"format": "\uf313 ",
"on-click": "anyrun",
"on-click-middle": "exec default_wall",
"on-click-right": "exec wallpaper_random",
"tooltip": false,
},
"custom/powermenu": {
"format": "\uf011",
"on-click": "wlogout",
"tooltip": false,
},
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "\uf06e",
"deactivated": "\uf070",
},
"tooltip": false,
},
"custom/playerctl": {
"format": "{icon} <span>{}</span>",
"return-type": "json",
"max-length": 55,
"exec": "playerctl -a metadata --format '{\"text\": \" {{markup_escape(title)}}\", \"tooltip\": \"{{playerName}} : {{markup_escape(title)}}\", \"alt\": \"{{status}}\", \"class\": \"{{status}}\"}' -F",
"on-click-middle": "playerctl previous",
"on-click": "playerctl play-pause",
"on-click-right": "playerctl next",
"format-icons": {
"Paused": "<span foreground='#6dd9d9'></span>",
"Playing": "<span foreground='#82db97'></span>",
},
},
"network": {
"interval": 5,
"format": "{ifname}",
"format-wifi": " {signalStrength}% Down: {bandwidthDownBytes} Up: {bandwidthUpBytes} {essid}",
"format-ethernet": " {ifname} Down: {bandwidthDownBytes} Up: {bandwidthUpBytes}",
"format-disconnected": "Disconnected ⚠",
"tooltip-format": " {ifname} via {gwaddri}",
"tooltip-format-wifi": " {ifname} @ {essid}\nIP: {ipaddr}\nStrength: {signalStrength}%\nFreq: {frequency}MHz\nDown: {bandwidthDownBytes} Up: {bandwidthUpBytes}",
"tooltip-format-ethernet": " {ifname}\nIP: {ipaddr}\n Down: {bandwidthDownBytes} Up: {bandwidthUpBytes}",
"tooltip-format-disconnected": "Disconnected",
"max-length": 50,
"on-click-middle": "nm-connection-editor",
"on-click-right": "foot nmtui",
},
"pulseaudio": {
//"format": "{volume}% {icon} {format_source}",
"format": "{icon} {volume}%",
"format-muted": " Mute",
"format-bluetooth": " {volume}% {format_source}",
"format-bluetooth-muted": " Mute",
"format-source": " {volume}%",
"format-source-muted": "",
"format-icons": {
"headphone": "",
"hands-free": "",
"headset": "",
"phone": "",
"portable": "",
"car": "",
"default": ["", "", ""],
},
"scroll-step": 5.0,
// Commands to execute on events
"on-click": "amixer set Master toggle",
"on-click-right": "GSK_RENDERER=opengl pavucontrol",
"smooth-scrolling-threshold": 1,
},
"temperature": {
"format": "\uf2c9 {temperatureC}\u00b0C",
"tooltip": false,
},
"backlight": {
"format": "{icon} {percent}%",
"format-icons": ["", "", "", "", "", "", "", "", ""],
},
"tray": {
"icon-size": 15,
"spacing": 5,
},
"battery": {
"interval": 60,
"states": {
"warning": 30,
"critical": 15,
},
"max-length": 20,
"format": "{icon} {capacity}%",
"format-warning": "{icon} {capacity}%",
"format-critical": "{icon} {capacity}%",
"format-charging": "<span font-family='Font Awesome 6 Free'></span> {capacity}%",
"format-plugged": " {capacity}%",
"format-alt": "{icon} {time}",
"format-full": " {capacity}%",
"format-icons": [" ", " ", " ", " ", " "],
},
}

View File

@@ -0,0 +1,38 @@
/*
* https://github.com/catppuccin/waybar/blob/main/themes/mocha.css
*
* Catppuccin Mocha palette
* Maintainer: rubyowo
*
*/
@define-color base #1e1e2e;
@define-color mantle #181825;
@define-color crust #11111b;
@define-color text #cdd6f4;
@define-color subtext0 #a6adc8;
@define-color subtext1 #bac2de;
@define-color surface0 #313244;
@define-color surface1 #45475a;
@define-color surface2 #585b70;
@define-color overlay0 #6c7086;
@define-color overlay1 #7f849c;
@define-color overlay2 #9399b2;
@define-color blue #89b4fa;
@define-color lavender #b4befe;
@define-color sapphire #74c7ec;
@define-color sky #89dceb;
@define-color teal #94e2d5;
@define-color green #a6e3a1;
@define-color yellow #f9e2af;
@define-color peach #fab387;
@define-color maroon #eba0ac;
@define-color red #f38ba8;
@define-color mauve #cba6f7;
@define-color pink #f5c2e7;
@define-color flamingo #f2cdcd;
@define-color rosewater #f5e0dc;

View File

@@ -0,0 +1,151 @@
@import "mocha.css";
* {
/* https://docs.gtk.org/gtk3/css-overview.html#colors */
color: @text;
font-family: "Maple Mono NF CN";
font-size: 12pt;
font-weight: bold;
border-radius: 8px;
transition-property: background-color;
transition-duration: 0.5s;
}
@keyframes blink_red {
to {
background-color: rgb(242, 143, 173);
color: rgb(26, 24, 38);
}
}
.warning,
.critical,
.urgent {
animation-name: blink_red;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
window#waybar {
background-color: transparent;
border: 2px solid alpha(@crust, 0.3);
}
window > box {
margin-left: 5px;
margin-right: 5px;
margin-top: 5px;
background-color: shade(@base, 0.9);
padding: 3px;
padding-left: 8px;
border: 2px none #33ccff;
}
#workspaces {
padding-left: 0px;
padding-right: 4px;
}
#workspaces button {
padding-top: 5px;
padding-bottom: 5px;
padding-left: 6px;
padding-right: 6px;
}
#workspaces button.active {
background-color: rgb(181, 232, 224);
color: rgb(26, 24, 38);
}
#workspaces button.urgent {
color: rgb(26, 24, 38);
}
#workspaces button:hover {
background-color: rgb(248, 189, 150);
color: rgb(26, 24, 38);
}
tooltip {
background: rgb(48, 45, 65);
}
tooltip label {
color: rgb(217, 224, 238);
}
#custom-launcher {
font-size: 20px;
padding-left: 8px;
padding-right: 6px;
color: #7ebae4;
}
#mode,
#clock,
#memory,
#temperature,
#cpu,
#custom-wall,
#temperature,
#backlight,
#pulseaudio,
#network,
#battery,
#custom-powermenu {
padding-left: 10px;
padding-right: 10px;
}
/* #mode { */
/* margin-left: 10px; */
/* background-color: rgb(248, 189, 150); */
/* color: rgb(26, 24, 38); */
/* } */
#memory {
color: rgb(181, 232, 224);
}
#cpu {
color: rgb(245, 194, 231);
}
#clock {
color: rgb(217, 224, 238);
}
#idle_inhibitor {
color: rgb(221, 182, 242);
padding-right: 8px;
}
#battery {
min-width: 55px;
color: rgb(126, 186, 244);
}
#battery.charging,
#battery.full,
#battery.plugged {
color: #26a65b;
}
#battery.critical:not(.charging) {
color: #f53c3c;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#custom-wall {
color: #33ccff;
}
#temperature {
color: rgb(150, 205, 251);
}
#backlight {
color: rgb(248, 189, 150);
}
#pulseaudio {
color: rgb(245, 224, 220);
}
#network {
color: #abe9b3;
}
#network.disconnected {
color: rgb(255, 255, 255);
}
#custom-powermenu {
color: rgb(242, 143, 173);
padding-right: 8px;
}
#tray {
padding-right: 8px;
padding-left: 10px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@@ -0,0 +1,36 @@
{
"label" : "lock",
"action" : "~/.config/hypr/scripts/lockscreen",
"text" : "Lock",
"keybind" : "l"
}
{
"label" : "hibernate",
"action" : "systemctl hibernate",
"text" : "Hibernate",
"keybind" : "h"
}
{
"label" : "logout",
"action" : "loginctl terminate-user $USER",
"text" : "Logout",
"keybind" : "e"
}
{
"label" : "shutdown",
"action" : "systemctl poweroff",
"text" : "Shutdown",
"keybind" : "s"
}
{
"label" : "suspend",
"action" : "systemctl suspend",
"text" : "Suspend",
"keybind" : "u"
}
{
"label" : "reboot",
"action" : "systemctl reboot",
"text" : "Reboot",
"keybind" : "r"
}

View File

@@ -0,0 +1,57 @@
/** ********** Fonts ********** **/
* {
font-family: "Maple Mono NF CN", sans-serif;
font-size: 14px;
font-weight: bold;
}
/** ********** Main Window ********** **/
window {
background-color: #1e1e2e;
}
/** ********** Buttons ********** **/
button {
background-color: #242434;
color: #ffffff;
border: 2px solid #282838;
border-radius: 20px;
background-repeat: no-repeat;
background-position: center;
background-size: 35%;
}
button:focus,
button:active,
button:hover {
background-color: #89b4fa;
outline-style: none;
}
/** ********** Icons ********** **/
#lock {
background-image: image(url("icons/lock.png"), url("/usr/share/wlogout/icons/lock.png"));
}
#logout {
background-image: image(url("icons/logout.png"), url("/usr/share/wlogout/icons/logout.png"));
}
#suspend {
background-image: image(url("icons/suspend.png"), url("/usr/share/wlogout/icons/suspend.png"));
}
#hibernate {
background-image: image(
url("icons/hibernate.png"),
url("/usr/share/wlogout/icons/hibernate.png")
);
}
#shutdown {
background-image: image(url("icons/shutdown.png"), url("/usr/share/wlogout/icons/shutdown.png"));
}
#reboot {
background-image: image(url("icons/reboot.png"), url("/usr/share/wlogout/icons/reboot.png"));
}

View File

@@ -0,0 +1,56 @@
{
config,
pkgs,
...
}:
{
imports = [
./anyrun.nix
];
home.packages = with pkgs; [
swaybg # the wallpaper
wl-clipboard # copying and pasting
hyprpicker # color picker
brightnessctl
hyprshot # screen shot
wf-recorder # screen recording
# audio
alsa-utils # provides amixer/alsamixer/...
networkmanagerapplet # provide GUI app: nm-connection-editor
];
xdg.configFile =
let
mkSymlink = config.lib.file.mkOutOfStoreSymlink;
confPath = "${config.home.homeDirectory}/nix-config/home/linux/gui/base/desktop/conf";
in
{
"mako".source = mkSymlink "${confPath}/mako";
"waybar".source = mkSymlink "${confPath}/waybar";
"wlogout".source = mkSymlink "${confPath}/wlogout";
"hypr/hypridle.conf".source = mkSymlink "${confPath}/hypridle.conf";
};
# status bar
programs.waybar = {
enable = true;
systemd.enable = true;
};
# Disable catppuccin to avoid conflict with my non-nix config.
catppuccin.waybar.enable = false;
# screen locker
programs.swaylock.enable = true;
# Logout Menu
programs.wlogout.enable = true;
catppuccin.wlogout.enable = false;
# Hyprland idle daemon
services.hypridle.enable = true;
# notification daemon, the same as dunst
services.mako.enable = true;
catppuccin.mako.enable = false;
}

View File

@@ -0,0 +1,54 @@
{
pkgs,
...
}:
{
home.packages = with pkgs; [
# firefox-wayland
nixpaks.firefox
nixpaks.firefox-desktop-item
];
programs = {
# source code: https://github.com/nix-community/home-manager/blob/master/modules/programs/chromium.nix
google-chrome = {
enable = true;
package = if pkgs.stdenv.isAarch64 then pkgs.chromium else pkgs.google-chrome;
# https://wiki.archlinux.org/title/Chromium#Native_Wayland_support
commandLineArgs = [
"--ozone-platform-hint=auto"
"--ozone-platform=wayland"
# make it use GTK_IM_MODULE if it runs with Gtk4, so fcitx5 can work with it.
# (only supported by chromium/chrome at this time, not electron)
"--gtk-version=4"
# make it use text-input-v1, which works for kwin 5.27 and weston
"--enable-wayland-ime"
# enable hardware acceleration - vulkan api
# "--enable-features=Vulkan"
];
};
vscode = {
enable = true;
package = pkgs.vscode.override {
isInsiders = false;
# https://wiki.archlinux.org/title/Wayland#Electron
commandLineArgs = [
"--ozone-platform-hint=auto"
"--ozone-platform=wayland"
# make it use GTK_IM_MODULE if it runs with Gtk4, so fcitx5 can work with it.
# (only supported by chromium/chrome at this time, not electron)
"--gtk-version=4"
# make it use text-input-v1, which works for kwin 5.27 and weston
"--enable-wayland-ime"
# TODO: fix https://github.com/microsoft/vscode/issues/187436
# still not works...
"--password-store=gnome" # use gnome-keyring as password store
];
};
};
};
}