add json support for helix

change notification app for niri from mako to swaync

add deno as json/jsonc formatter in helix

add wluma to control backlight

add taplo as toml formatter

refactor waybar, and use waybar default config

change gpg pinentry to shell script which can determine which session type is used

fix error when SSH_CLIENT is unbind in pinentry script

fix pinentry selector in pkgs
This commit is contained in:
ulic-youthlic 2025-01-15 13:37:41 +08:00
parent a20699531d
commit 47550dfff7
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
16 changed files with 459 additions and 8 deletions

View file

@ -9,6 +9,8 @@
{
imports = [
./niri
./wluma
./waybar
];
youthlic.programs = {

View file

@ -126,7 +126,7 @@ environment {
DISPLAY ":1"
}
spawn-at-startup "waybar"
spawn-at-startup "mako"
spawn-at-startup "swaync"
spawn-at-startup "swaybg" "-i" "/home/david/wallpaper/01.png"
spawn-at-startup "fcitx5" "-d" "--replace"
spawn-at-startup "xwayland-satellite" ":1"

View file

@ -0,0 +1,215 @@
// -*- mode: jsonc -*-
{
// "layer": "top", // Waybar at top layer
// "position": "bottom", // Waybar position (top|bottom|left|right)
"height": 30, // Waybar height (to be removed for auto height)
// "width": 1280, // Waybar width
"spacing": 4, // Gaps between modules (4px)
// Choose the order of the modules
"modules-left": [
"sway/workspaces",
"sway/mode",
"sway/scratchpad",
"custom/media"
],
"modules-center": [
"sway/window"
],
"modules-right": [
"mpd",
"idle_inhibitor",
"pulseaudio",
"network",
"power-profiles-daemon",
"cpu",
"memory",
"temperature",
"backlight",
"keyboard-state",
"sway/language",
"battery",
"battery#bat2",
"clock",
"tray",
"custom/power"
],
// Modules configuration
// "sway/workspaces": {
// "disable-scroll": true,
// "all-outputs": true,
// "warp-on-scroll": false,
// "format": "{name}: {icon}",
// "format-icons": {
// "1": "",
// "2": "",
// "3": "",
// "4": "",
// "5": "",
// "urgent": "",
// "focused": "",
// "default": ""
// }
// },
"keyboard-state": {
"numlock": true,
"capslock": true,
"format": "{name} {icon}",
"format-icons": {
"locked": "",
"unlocked": ""
}
},
"sway/mode": {
"format": "<span style=\"italic\">{}</span>"
},
"sway/scratchpad": {
"format": "{icon} {count}",
"show-empty": false,
"format-icons": ["", ""],
"tooltip": true,
"tooltip-format": "{app}: {title}"
},
"mpd": {
"format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ",
"format-disconnected": "Disconnected ",
"format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ",
"unknown-tag": "N/A",
"interval": 5,
"consume-icons": {
"on": " "
},
"random-icons": {
"off": "<span color=\"#f53c3c\"></span> ",
"on": " "
},
"repeat-icons": {
"on": " "
},
"single-icons": {
"on": "1 "
},
"state-icons": {
"paused": "",
"playing": ""
},
"tooltip-format": "MPD (connected)",
"tooltip-format-disconnected": "MPD (disconnected)"
},
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "",
"deactivated": ""
}
},
"tray": {
// "icon-size": 21,
"spacing": 10
},
"clock": {
// "timezone": "America/New_York",
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
"format-alt": "{:%Y-%m-%d}"
},
"cpu": {
"format": "{usage}% ",
"tooltip": false
},
"memory": {
"format": "{}% "
},
"temperature": {
// "thermal-zone": 2,
// "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input",
"critical-threshold": 80,
// "format-critical": "{temperatureC}°C {icon}",
"format": "{temperatureC}°C {icon}",
"format-icons": ["", "", ""]
},
"backlight": {
// "device": "acpi_video1",
"format": "{percent}% {icon}",
"format-icons": ["", "", "", "", "", "", "", "", ""]
},
"battery": {
"states": {
// "good": 95,
"warning": 30,
"critical": 15
},
"format": "{capacity}% {icon}",
"format-full": "{capacity}% {icon}",
"format-charging": "{capacity}% ",
"format-plugged": "{capacity}% ",
"format-alt": "{time} {icon}",
// "format-good": "", // An empty format will hide the module
// "format-full": "",
"format-icons": ["", "", "", "", ""]
},
"battery#bat2": {
"bat": "BAT2"
},
"power-profiles-daemon": {
"format": "{icon}",
"tooltip-format": "Power profile: {profile}\nDriver: {driver}",
"tooltip": true,
"format-icons": {
"default": "",
"performance": "",
"balanced": "",
"power-saver": ""
}
},
"network": {
// "interface": "wlp2*", // (Optional) To force the use of this interface
"format-wifi": "{essid} ({signalStrength}%) ",
"format-ethernet": "{ipaddr}/{cidr} ",
"tooltip-format": "{ifname} via {gwaddr} ",
"format-linked": "{ifname} (No IP) ",
"format-disconnected": "Disconnected ⚠",
"format-alt": "{ifname}: {ipaddr}/{cidr}"
},
"pulseaudio": {
// "scroll-step": 1, // %, can be a float
"format": "{volume}% {icon} {format_source}",
"format-bluetooth": "{volume}% {icon} {format_source}",
"format-bluetooth-muted": " {icon} {format_source}",
"format-muted": " {format_source}",
"format-source": "{volume}% ",
"format-source-muted": "",
"format-icons": {
"headphone": "",
"hands-free": "",
"headset": "",
"phone": "",
"portable": "",
"car": "",
"default": ["", "", ""]
},
"on-click": "pavucontrol"
},
"custom/media": {
"format": "{icon} {text}",
"return-type": "json",
"max-length": 40,
"format-icons": {
"spotify": "",
"default": "🎜"
},
"escape": true,
"exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder
// "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name
},
"custom/power": {
"format": "⏻ ",
"tooltip": false,
"menu": "on-click",
"menu-file": "$HOME/.config/waybar/power_menu.xml", // Menu file in resources folder
"menu-actions": {
"shutdown": "shutdown",
"reboot": "reboot",
"suspend": "systemctl suspend",
"hibernate": "systemctl hibernate"
}
}
}

View file

@ -0,0 +1,4 @@
{ ... }:
{
youthlic.programs.waybar.configDir = ./config;
}

View file

@ -0,0 +1,25 @@
# [als.iio]
# path = "/sys/bus/iio/devices"
# thresholds = { 0 = "night", 20 = "dark", 80 = "dim", 250 = "normal", 500 = "bright", 800 = "outdoors" }
[als.webcam]
video = 0
thresholds = { 0 = "night", 15 = "dark", 30 = "dim", 45 = "normal", 60 = "bright", 75 = "outdoors" }
# [als.time]
# thresholds = { 0 = "night", 7 = "dark", 9 = "dim", 11 = "normal", 13 = "bright", 16 = "normal", 18 = "dark", 20 = "night" }
# [als.none]
[[output.backlight]]
name = "eDP-1"
path = "/sys/class/backlight/intel_backlight"
capturer = "wayland"
# [[output.ddcutil]]
# name = "Dell Inc. DELL P2415Q"
# capturer = "none"
[[keyboard]]
name = "keyboard-asus"
path = "/sys/bus/platform/devices/asus-nb-wmi/leds/asus::kbd_backlight"

View file

@ -0,0 +1,4 @@
{ ... }:
{
youthlic.programs.wluma.config = ./config.toml;
}

View file

@ -17,6 +17,8 @@
./fuzzel.nix
./firefox.nix
./niri.nix
./wluma.nix
./waybar.nix
];
options = {

View file

@ -2,6 +2,7 @@
pkgs,
config,
lib,
outputs,
...
}:
{
@ -26,7 +27,7 @@
{
enable = true;
enableSshSupport = true;
pinentryPackage = pkgs.pinentry-curses;
pinentryPackage = outputs.packages."${pkgs.system}".pinentry-selector;
}
(lib.mkIf config.youthlic.programs.fish.enable {
enableFishIntegration = true;

View file

@ -23,6 +23,7 @@
nixd
deno
nixfmt-rfc-style
nodePackages_latest.vscode-json-languageserver
];
example = (
with pkgs;
@ -50,6 +51,76 @@
config = builtins.fromTOML config-file;
in
config;
languages = {
language-server = {
vscode-json-languageserver = {
command = "vscode-json-languageserver";
args = [ "--stdio" ];
config = {
provideFormatter = true;
json = {
validate = {
enable = true;
};
};
};
};
};
language = [
{
name = "toml";
formatter = {
command = "taplo";
args = [
"fmt"
"-"
];
};
}
{
name = "markdown";
formatter = {
command = "deno";
args = [
"fmt"
"-"
"--ext"
"md"
];
};
}
{
name = "json";
language-servers = [
"vscode-json-languageserver"
];
formatter = {
command = "deno";
args = [
"fmt"
"-"
"--ext"
"json"
];
};
}
{
name = "jsonc";
language-servers = [
"vscode-json-languageserver"
];
formatter = {
command = "deno";
args = [
"fmt"
"-"
"--ext"
"jsonc"
];
};
}
];
};
};
home.packages = cfg.extraPackages;
};

View file

@ -22,13 +22,14 @@ in
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
mako
swaynotificationcenter
swaybg
xwayland-satellite
waybar
];
youthlic.programs = {
fuzzel.enable = true;
wluma.enable = true;
waybar.enable = true;
};
programs.niri = {
config = builtins.readFile cfg.config;

33
home/modules/waybar.nix Normal file
View file

@ -0,0 +1,33 @@
{
pkgs,
config,
lib,
...
}:
let
cfg = config.youthlic.programs.waybar;
in
{
options = {
youthlic.programs.waybar = {
enable = lib.mkEnableOption "waybar";
configDir = lib.mkOption {
type = lib.types.path;
example = ./config;
description = ''
path to waybar config dir
'';
};
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
waybar
];
xdg.configFile."waybar" = {
enable = true;
source = cfg.configDir;
recursive = true;
};
};
}

57
home/modules/wluma.nix Normal file
View file

@ -0,0 +1,57 @@
{
config,
pkgs,
lib,
...
}:
let
cfg = config.youthlic.programs.wluma;
in
{
options = {
youthlic.programs.wluma = {
enable = lib.mkEnableOption "wluma";
config = lib.mkOption {
type = lib.types.path;
example = ./config.toml;
description = ''
path to config file of wluma
'';
};
package = lib.mkOption {
type = lib.types.package;
example = pkgs.wluam;
default = pkgs.wluma;
description = ''
pakcage of wluma
'';
};
};
};
config = lib.mkIf cfg.enable {
home.packages = [
cfg.package
];
xdg.configFile."wluma/config.toml" = {
enable = true;
source = cfg.config;
};
systemd.user.services.wluma = {
Unit = {
Description = "Adjusting screen brightness based on screen contents and amount of ambient light";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart = [ "${lib.getExe cfg.package}" ];
Restart = "always";
EnvironmentFile = [ "-%E/wluma/service.conf" ];
PrivateNetwork = true;
PrivateMounts = false;
};
Install = {
WantedBy = [ "graphical-session.target" ];
};
};
};
}

View file

@ -29,14 +29,14 @@
openssh.enable = true;
steam.enable = true;
};
gui.enabled = "niri";
gui.enabled = "cosmic";
};
specialisation = {
cosmic = {
niri = {
inheritParentConfig = true;
configuration = {
youthlic.gui.enabled = lib.mkForce "cosmic";
youthlic.gui.enabled = lib.mkForce "niri";
};
};
};

View file

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ lib, pkgs, ... }:
{
users.users.david = {
isNormalUser = true;
@ -7,8 +7,18 @@
"networkmanager"
"libvirtd"
"wheel"
"video"
];
};
services.udev = {
enable = true;
extraRules = ''
ACTION=="add", SUBSYSTEM=="backlight", RUN+="${lib.getExe' pkgs.coreutils "chgrp"} video /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="backlight", RUN+="${lib.getExe' pkgs.coreutils "chmod"} g+w /sys/class/backlight/%k/brightness"
ACTION=="add", SUBSYSTEM=="leds", RUN+="${lib.getExe' pkgs.coreutils "chgrp"} video /sys/class/leds/%k/brightness"
ACTION=="add", SUBSYSTEM=="leds", RUN+="${lib.getExe' pkgs.coreutils "chmod"} g+w /sys/class/leds/%k/brightness"
'';
};
programs.fish.enable = true;
users.users.david.shell = pkgs.fish;
users.users.david.openssh.authorizedKeys.keyFiles = [

View file

@ -4,6 +4,7 @@
...
}:
{
pinentry-selector = pkgs.callPackage ./pinentry-selector.nix { };
immersive-translate =
(pkgs.callPackage "${inputs.firefox-addons}/default.nix" { }).firefox-addons.immersive-translate;
}

View file

@ -0,0 +1,25 @@
{ pkgs }:
pkgs.writeShellApplication {
name = "pinentry";
runtimeInputs = with pkgs; [
pinentry-all
];
text = ''
if [ -v XDG_SESSION_TYPE ]; then
case $XDG_SESSION_TYPE in
tty)
pinentry-tty;;
*)
pinentry-qt;;
esac
elif [ -v SSH_CLIENT ] && [ -n "$SSH_CLIENT" ]; then
pinentry-tty
elif [ -v WAYLAND_DISPLAY ] && [ -n "$WAYLAND_DISPLAY" ]; then
pinentry-qt
elif [ -v DISPLAY ] && [ -n "$DISPLAY" ]; then
pinentry-qt
else
pinentry-tty
fi
'';
}