Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d6ffd7785 | |||
| 647f56d213 | |||
| 210aa544fc | |||
| 5e83259bcb | |||
| 0a2aae246a | |||
| 30881f356a | |||
| 3aaaeb49ca | |||
| 55e12cddaf | |||
| ac4f625768 | |||
| 2d44bc6006 | |||
| 03c1d14ed9 | |||
| 73a746cebd | |||
| 1e9dc4df4b | |||
| 7dd55a5de9 | |||
| e61116140d | |||
| b75b79057b | |||
| 1f08d10ac7 | |||
| b2cf885637 | |||
| 44eb487df9 | |||
| 006bf56fd7 | |||
| 73e3707570 |
@@ -13,9 +13,15 @@
|
||||
i3:
|
||||
nixos-rebuild switch --flake .#ai_i3 --use-remote-sudo
|
||||
|
||||
s-i3:
|
||||
nixos-rebuild switch --flake .#shoukei_i3 --use-remote-sudo
|
||||
|
||||
hypr:
|
||||
nixos-rebuild switch --flake .#ai_hyprland --use-remote-sudo
|
||||
|
||||
s-hypr:
|
||||
nixos-rebuild switch --flake .#shoukei_hyprland --use-remote-sudo
|
||||
|
||||
i3-debug:
|
||||
nixos-rebuild switch --flake .#ai_i3 --use-remote-sudo --show-trace --verbose
|
||||
|
||||
@@ -36,9 +42,6 @@ history:
|
||||
repl:
|
||||
nix repl -f flake:nixpkgs
|
||||
|
||||
eye:
|
||||
systemctl --user start gammastep.service
|
||||
|
||||
gc:
|
||||
# remove all generations older than 7 days
|
||||
sudo nix profile wipe-history --profile /nix/var/nix/profiles/system --older-than 7d
|
||||
@@ -156,6 +159,3 @@ fmt:
|
||||
# format the nix files in this repo
|
||||
nix fmt
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf result
|
||||
|
||||
@@ -83,7 +83,7 @@ See [./secrets](./secrets) for details.
|
||||
|
||||
For NixOS:
|
||||
|
||||
> To deploy this flake from NixOS's official ISO image(purest installation method), please refer to [./hosts/idols/ai/nixos-installer/](./hosts/idols/ai/nixos-installer/)
|
||||
> To deploy this flake from NixOS's official ISO image(purest installation method), please refer to [./nixos-installer/](./nixos-installer/)
|
||||
|
||||
> Need to restart the machine when switching between `wayland` and `xorg`.
|
||||
|
||||
@@ -161,6 +161,7 @@ Other dotfiles that inspired me:
|
||||
- [fufexan/dotfiles](https://github.com/fufexan/dotfiles): gtk theme, xdg, git, media, anyrun, etc.
|
||||
- Modularized NixOS Configuration
|
||||
- [hlissner/dotfiles](https://github.com/hlissner/dotfiles)
|
||||
- [viperML/dotfiles](https://github.com/viperML/dotfiles)
|
||||
- Hyprland(wayland)
|
||||
- [notwidow/hyprland](https://github.com/notwidow/hyprland): This is where I start my hyprland journey.
|
||||
- [HeinzDev/Hyprland-dotfiles](https://github.com/HeinzDev/Hyprland-dotfiles): Refer to the waybar configuration here.
|
||||
|
||||
@@ -533,6 +533,22 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixos-hardware": {
|
||||
"locked": {
|
||||
"lastModified": 1702453208,
|
||||
"narHash": "sha256-0wRi9SposfE2wHqjuKt8WO2izKB/ASDOV91URunIqgo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "7763c6fd1f299cb9361ff2abf755ed9619ef01d6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "master",
|
||||
"repo": "nixos-hardware",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixos-licheepi4a": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
@@ -836,6 +852,7 @@
|
||||
"mysecrets": "mysecrets",
|
||||
"nix-darwin": "nix-darwin",
|
||||
"nixos-generators": "nixos-generators",
|
||||
"nixos-hardware": "nixos-hardware",
|
||||
"nixos-licheepi4a": "nixos-licheepi4a",
|
||||
"nixos-rk3588": "nixos-rk3588",
|
||||
"nixpkgs": "nixpkgs_3",
|
||||
@@ -952,11 +969,11 @@
|
||||
"wallpapers": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1694759298,
|
||||
"narHash": "sha256-eSDBX6aA7zxodUq3MmV99JS0vr+aUwbEuLPoKnU5kHg=",
|
||||
"lastModified": 1703310017,
|
||||
"narHash": "sha256-SL3PIDa4BNz2rDZ/9KwnJCAfhelIoqpLtQ/FSYgfusI=",
|
||||
"owner": "ryan4yin",
|
||||
"repo": "wallpapers",
|
||||
"rev": "f59f49a44042d2c669e18da07e652e00c431e9e9",
|
||||
"rev": "20dea02ee2c0bb74dadcc3d4ec5efe78d00520dc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -95,18 +95,13 @@
|
||||
# nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
|
||||
# add git hooks to format nix code before commit
|
||||
pre-commit-hooks = {
|
||||
url = "github:cachix/pre-commit-hooks.nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
# for macos
|
||||
nixpkgs-darwin.url = "github:nixos/nixpkgs/nixpkgs-23.11-darwin";
|
||||
nix-darwin = {
|
||||
url = "github:lnl7/nix-darwin";
|
||||
inputs.nixpkgs.follows = "nixpkgs-darwin";
|
||||
};
|
||||
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
|
||||
|
||||
# home-manager, used for managing user configuration
|
||||
home-manager = {
|
||||
@@ -153,6 +148,12 @@
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
# add git hooks to format nix code before commit
|
||||
pre-commit-hooks = {
|
||||
url = "github:cachix/pre-commit-hooks.nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
######################## Some non-flake repositories #########################################
|
||||
|
||||
# AstroNvim is an aesthetic and feature-rich neovim config.
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
{username, ...}: {
|
||||
imports = [
|
||||
];
|
||||
|
||||
# Home Manager needs a bit of information about you and the
|
||||
# paths it should manage.
|
||||
home = {
|
||||
inherit username;
|
||||
homeDirectory = "/home/${username}";
|
||||
|
||||
|
||||
# This value determines the Home Manager release that your
|
||||
# configuration is compatible with. This helps avoid breakage
|
||||
@@ -1,6 +1,3 @@
|
||||
{...}: {
|
||||
imports = [
|
||||
./container.nix
|
||||
./kubernetes.nix
|
||||
];
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,3 @@
|
||||
{...}: {
|
||||
imports = [
|
||||
../server
|
||||
|
||||
./cloud
|
||||
./container
|
||||
./neovim
|
||||
./terminal
|
||||
|
||||
./development.nix
|
||||
./helix.nix
|
||||
./media.nix
|
||||
./shell.nix
|
||||
./yazi.nix
|
||||
];
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ return {
|
||||
{ import = "astrocommunity.colorscheme.catppuccin" },
|
||||
-- Highly experimental plugin that completely replaces
|
||||
-- the UI for messages, cmdline and the popupmenu.
|
||||
{ import = "astrocommunity.utility.noice-nvim" },
|
||||
-- { import = "astrocommunity.utility.noice-nvim" },
|
||||
-- Fully featured & enhanced replacement for copilot.vim
|
||||
-- <Tab> work with both auto completion in cmp and copilot
|
||||
{ import = "astrocommunity.media.vim-wakatime" },
|
||||
@@ -77,7 +77,7 @@ return {
|
||||
-- lazy-loading on events
|
||||
event = { "InsertLeave", "TextChanged" },
|
||||
opts = function(_, opts)
|
||||
opts.prompt_style = "notify" -- or stdout
|
||||
opts.prompt_style = "stdout" -- notify or stdout
|
||||
end,
|
||||
},
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@
|
||||
{
|
||||
xdg.configFile = {
|
||||
# astronvim's config
|
||||
"nvim".source = astronvim;
|
||||
"nvim" = {
|
||||
source = astronvim;
|
||||
force = true;
|
||||
};
|
||||
|
||||
# my custom astronvim config, astronvim will load it after base config
|
||||
# https://github.com/AstroNvim/AstroNvim/blob/v3.32.0/lua/astronvim/bootstrap.lua#L15-L16
|
||||
@@ -33,9 +36,10 @@
|
||||
vimAlias = true;
|
||||
|
||||
# currently we use lazy.nvim as neovim's package manager, so comment this one.
|
||||
# plugins = with pkgs.vimPlugins; [
|
||||
# # search all the plugins using https://search.nixos.org/packages
|
||||
# ];
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
# search all the plugins using https://search.nixos.org/packages
|
||||
telescope-fzf-native-nvim
|
||||
];
|
||||
|
||||
# Extra packages only available to nvim(won't pollute the global home environment)
|
||||
extraPackages = with pkgs;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{pkgs, ...}: {
|
||||
_: {
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
|
||||
@@ -23,13 +23,6 @@
|
||||
# required to prevent sending default identity files first.
|
||||
IdentitiesOnly yes
|
||||
|
||||
Host github.com
|
||||
# github is controlled by gluttony~
|
||||
IdentityFile ~/.ssh/gluttony
|
||||
# Specifies that ssh should only use the identity file explicitly configured above
|
||||
# required to prevent sending default identity files first.
|
||||
IdentitiesOnly yes
|
||||
|
||||
Host gtr5
|
||||
HostName 192.168.5.172
|
||||
Port 22
|
||||
@@ -1,7 +1,3 @@
|
||||
{...}: {
|
||||
imports = [
|
||||
./alacritty.nix
|
||||
./kitty.nix
|
||||
./wezterm.nix
|
||||
];
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
{...}: {
|
||||
imports = [
|
||||
./shells
|
||||
./tmux
|
||||
./zellij
|
||||
|
||||
./bat.nix
|
||||
./btop.nix
|
||||
./core.nix
|
||||
./git.nix
|
||||
./starship.nix
|
||||
];
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
|
||||
@@ -1,44 +1,3 @@
|
||||
{pkgs, ...}: {
|
||||
##########################################################################
|
||||
#
|
||||
# MacOS specific home configuration
|
||||
#
|
||||
##########################################################################
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
|
||||
# all my ssh private key are generated by `ssh-keygen -t ed25519 -C "ryan@nickname"`
|
||||
# the config's format:
|
||||
# Host — given the pattern used to match against the host name given on the command line.
|
||||
# HostName — specify nickname or abbreviation for host
|
||||
# IdentityFile — the location of your SSH key authentication file for the account.
|
||||
# format in details:
|
||||
# https://www.ssh.com/academy/ssh/config
|
||||
extraConfig = ''
|
||||
# a private key that is used during authentication will be added to ssh-agent if it is running
|
||||
AddKeysToAgent yes
|
||||
|
||||
Host 192.168.*
|
||||
# allow to securely use local SSH agent to authenticate on the remote machine.
|
||||
# It has the same effect as adding cli option `ssh -A user@host`
|
||||
ForwardAgent yes
|
||||
# romantic holds my homelab~
|
||||
IdentityFile ~/.ssh/romantic
|
||||
# Specifies that ssh should only use the identity file explicitly configured above
|
||||
# required to prevent sending default identity files first.
|
||||
IdentitiesOnly yes
|
||||
|
||||
Host github.com
|
||||
Hostname github.com
|
||||
# github is controlled by gluttony~
|
||||
IdentityFile ~/.ssh/harmonica
|
||||
# Specifies that ssh should only use the identity file explicitly configured above
|
||||
# required to prevent sending default identity files first.
|
||||
IdentitiesOnly yes
|
||||
'';
|
||||
};
|
||||
{username, ...}: {
|
||||
home.homeDirectory = "/Users/${username}";
|
||||
}
|
||||
|
||||
@@ -1,31 +1,9 @@
|
||||
{username, ...}: {
|
||||
imports = [
|
||||
{mylib, ...}: {
|
||||
imports =
|
||||
(mylib.scanPaths ./.)
|
||||
++ [
|
||||
../base/server
|
||||
../base/desktop
|
||||
|
||||
./proxychains
|
||||
./core.nix
|
||||
./rime-squirrel.nix
|
||||
./shell.nix
|
||||
../base/core.nix
|
||||
];
|
||||
|
||||
# Home Manager needs a bit of information about you and the
|
||||
# paths it should manage.
|
||||
home = {
|
||||
inherit username;
|
||||
# set homeDirectory make build fail
|
||||
homeDirectory = "/Users/${username}";
|
||||
|
||||
# This value determines the Home Manager release that your
|
||||
# configuration is compatible with. This helps avoid breakage
|
||||
# when a new Home Manager release introduces backwards
|
||||
# incompatible changes.
|
||||
#
|
||||
# You can update Home Manager without changing this value. See
|
||||
# the Home Manager release notes for a list of state version
|
||||
# changes in each release.
|
||||
stateVersion = "23.11";
|
||||
};
|
||||
|
||||
# Let Home Manager install and manage itself.
|
||||
programs.home-manager.enable = true;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
_: {
|
||||
{
|
||||
# Homebrew's default install location:
|
||||
# /opt/homebrew for Apple Silicon
|
||||
# /usr/local for macOS Intel
|
||||
# The prefix /opt/homebrew was chosen to allow installations
|
||||
# in /opt/homebrew for Apple Silicon and /usr/local for Rosetta 2 to coexist and use bottles.
|
||||
programs.bash.bashrcExtra = ''
|
||||
programs.bash = {
|
||||
enable = true;
|
||||
bashrcExtra = ''
|
||||
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
|
||||
'';
|
||||
programs.zsh.envExtra = ''
|
||||
};
|
||||
programs.zsh = {
|
||||
enable = true;
|
||||
envExtra = ''
|
||||
export PATH="/opt/homebrew/bin:/usr/local/bin:$PATH"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,3 +11,13 @@
|
||||
1. used by my hyprland desktop.
|
||||
7. `desktop-i3.nix`: the entrypoint of i3's configuration, it import all the submodules above, except `hyprland`.
|
||||
1. used by my i3 desktop.
|
||||
|
||||
|
||||
## Why install I3/Hyprland in Home Manager instead of a NixOS Module?
|
||||
|
||||
1. I3 & Hyprland's configuration file is located in `~/.config`, which can be easily managed by Home Manager.
|
||||
2. There're other user-specific systemd servcies, such gammastep, wallpaper-switcher, etc. which can be easily managed by Home Manager, but if we start i3/hyprland in NixOS Module, they may failed to start automatically. With i3/hyprland installed via home-manager, we can control their systemd service's dependent order, to avoid issues like this.
|
||||
3. By install as less as possible in NixOS Module, we can:
|
||||
1. Make the NixOS system more secure and stable.
|
||||
2. Make this flake more portable to other non-NixOS systems, as home-manager can be installed on any Linux system.
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
{
|
||||
imports = [
|
||||
./shell.nix
|
||||
./system-tools.nix
|
||||
];
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
{
|
||||
config,
|
||||
nushell-scripts,
|
||||
...
|
||||
}: let
|
||||
|
||||
{config, username, ...}: let
|
||||
d = config.xdg.dataHome;
|
||||
c = config.xdg.configHome;
|
||||
cache = config.xdg.cacheHome;
|
||||
in rec {
|
||||
# add environment variables
|
||||
systemd.user.sessionVariables = {
|
||||
|
||||
home.homeDirectory = "/home/${username}";
|
||||
|
||||
# environment variables that always set at login
|
||||
home.sessionVariables = {
|
||||
# clean up ~
|
||||
LESSHISTFILE = cache + "/less/history";
|
||||
LESSKEY = c + "/less/lesskey";
|
||||
@@ -24,9 +24,5 @@ in rec {
|
||||
|
||||
# enable scrolling in git diff
|
||||
DELTA_PAGER = "less -R";
|
||||
|
||||
MANPAGER = "sh -c 'col -bx | bat -l man -p'";
|
||||
};
|
||||
|
||||
home.sessionVariables = systemd.user.sessionVariables;
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
{username, ...}: {
|
||||
imports = [
|
||||
../base/desktop
|
||||
|
||||
./base
|
||||
./fcitx5
|
||||
./desktop
|
||||
|
||||
./hyprland
|
||||
];
|
||||
|
||||
# Home Manager needs a bit of information about you and the
|
||||
# paths it should manage.
|
||||
home = {
|
||||
inherit username;
|
||||
homeDirectory = "/home/${username}";
|
||||
|
||||
# This value determines the Home Manager release that your
|
||||
# configuration is compatible with. This helps avoid breakage
|
||||
# when a new Home Manager release introduces backwards
|
||||
# incompatible changes.
|
||||
#
|
||||
# You can update Home Manager without changing this value. See
|
||||
# the Home Manager release notes for a list of state version
|
||||
# changes in each release.
|
||||
stateVersion = "23.11";
|
||||
};
|
||||
|
||||
# Let Home Manager install and manage itself.
|
||||
programs.home-manager.enable = true;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
{username, ...}: {
|
||||
imports = [
|
||||
../base/desktop
|
||||
|
||||
./base
|
||||
./fcitx5
|
||||
./desktop
|
||||
|
||||
./i3
|
||||
];
|
||||
|
||||
# Home Manager needs a bit of information about you and the
|
||||
# paths it should manage.
|
||||
home = {
|
||||
inherit username;
|
||||
homeDirectory = "/home/${username}";
|
||||
|
||||
# This value determines the Home Manager release that your
|
||||
# configuration is compatible with. This helps avoid breakage
|
||||
# when a new Home Manager release introduces backwards
|
||||
# incompatible changes.
|
||||
#
|
||||
# You can update Home Manager without changing this value. See
|
||||
# the Home Manager release notes for a list of state version
|
||||
# changes in each release.
|
||||
stateVersion = "23.11";
|
||||
};
|
||||
|
||||
# Let Home Manager install and manage itself.
|
||||
programs.home-manager.enable = true;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
imports = [
|
||||
../base/server
|
||||
../base/desktop
|
||||
../base/core.nix
|
||||
|
||||
./base
|
||||
./desktop
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
gtk.enable = true;
|
||||
x11.enable = true;
|
||||
package = pkgs.bibata-cursors;
|
||||
name = "Bibata-Modern-Classic";
|
||||
name = "Bibata-Modern-Ice";
|
||||
size = 24;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{pkgs, ...}: {
|
||||
home.packages = with pkgs; [
|
||||
# GUI apps
|
||||
# e-book viewer(.epub/.mobi/...)
|
||||
# do not support .pdf
|
||||
foliate
|
||||
|
||||
# instant messaging
|
||||
telegram-desktop
|
||||
discord
|
||||
qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq
|
||||
|
||||
# remote desktop(rdp connect)
|
||||
remmina
|
||||
freerdp # required by remmina
|
||||
|
||||
# misc
|
||||
flameshot
|
||||
ventoy # multi-boot usb creator
|
||||
];
|
||||
|
||||
# GitHub CLI tool
|
||||
programs.gh = {
|
||||
enable = true;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
wallpapers,
|
||||
...
|
||||
}: {
|
||||
systemd.user.services.wallpaper = {
|
||||
Unit = {
|
||||
Description = "Wallpaper Switcher daemon";
|
||||
After = ["graphical-session-pre.target" "xdg-desktop-autostart.target"];
|
||||
Wants = ["graphical-session-pre.target"];
|
||||
};
|
||||
Install.WantedBy = ["graphical-session.target"];
|
||||
Service = {
|
||||
ExecStart = lib.getExe (pkgs.writeShellApplication {
|
||||
name = "wallpaper";
|
||||
runtimeInputs = with pkgs; [procps feh swaybg python3];
|
||||
text = ''
|
||||
export WALLPAPERS_DIR="${wallpapers}"
|
||||
export WALLPAPERS_STATE_FILEPATH="${config.xdg.stateHome}/wallpaper-switcher/switcher_state"
|
||||
export WALLPAPER_WAIT_MIN=10
|
||||
export WALLPAPER_WAIT_MAX=20
|
||||
exec ${./wallpaper-switcher.py}
|
||||
'';
|
||||
});
|
||||
RestartSec = 3;
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
This script will randomly select a wallpaper from the wallpapers directory.
|
||||
It will skip the last wallpaper used, so that you don't get the same wallpaper.
|
||||
|
||||
It will also set the wallpaper using `feh` for X11, or `swaybg` for Wayland.
|
||||
|
||||
Maintainer: ryan4yin [xiaoyin_c@qq.com]
|
||||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
import random
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Union
|
||||
import subprocess
|
||||
import logging
|
||||
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class WallpaperSwitcher:
|
||||
def __init__(
|
||||
self,
|
||||
wait_min,
|
||||
wait_max,
|
||||
wallpapers_dir: Path,
|
||||
state_filepath: Path,
|
||||
image_extensions: Union[tuple, list],
|
||||
) -> None:
|
||||
self.wallpapers_dir = wallpapers_dir
|
||||
self.image_extensions = image_extensions
|
||||
self.state_filepath = state_filepath
|
||||
self.wait_min = wait_min
|
||||
self.wait_max = wait_max
|
||||
|
||||
# initialize the state file
|
||||
self.state_filepath.parent.mkdir(parents=True, exist_ok=True)
|
||||
self.current_state = self.state_filepath.open("a+", encoding="utf-8")
|
||||
self.current_wallpaper_list = list()
|
||||
|
||||
def run(self):
|
||||
"""
|
||||
Iterate on all wallpapers in the wallpapers directory, cycling through them in a random order.
|
||||
"""
|
||||
self.initialize_state()
|
||||
while True:
|
||||
for i, w in enumerate(self.current_wallpaper_list):
|
||||
if i < self.current_wallpaper_index:
|
||||
continue
|
||||
|
||||
logger.info(
|
||||
f"Setting wallpaper {i+1}/{len(self.current_wallpaper_list)}: {w}"
|
||||
)
|
||||
self.set_wallpaper(w)
|
||||
|
||||
# update the state
|
||||
self.current_wallpaper_index = i
|
||||
self.save_state()
|
||||
|
||||
wait_time = random.randint(self.wait_min, self.wait_max)
|
||||
logger.info(f"Waiting {wait_time} seconds...")
|
||||
time.sleep(wait_time)
|
||||
|
||||
# reset the state
|
||||
self.reset_state()
|
||||
|
||||
def save_state(self):
|
||||
wallpaper_list = [w.as_posix() for w in self.current_wallpaper_list]
|
||||
state = {
|
||||
"current_wallpaper_list": wallpaper_list,
|
||||
"current_wallpaper_index": self.current_wallpaper_index,
|
||||
}
|
||||
self.current_state.truncate(0)
|
||||
self.current_state.write(json.dumps(state, indent=4))
|
||||
self.current_state.flush()
|
||||
|
||||
def initialize_state(self):
|
||||
self.current_state.seek(0)
|
||||
data = self.current_state.read()
|
||||
if not data:
|
||||
logger.info("No state found, resetting...")
|
||||
self.reset_state()
|
||||
else:
|
||||
logger.info("State found, reloading...")
|
||||
state = json.loads(data)
|
||||
wallpapers = [Path(w) for w in state["current_wallpaper_list"]]
|
||||
self.current_wallpaper_list = wallpapers
|
||||
self.current_wallpaper_index = state["current_wallpaper_index"]
|
||||
|
||||
def reset_state(self):
|
||||
logger.info(f"Rescanning & shuffle wallpapers in {self.wallpapers_dir} ...")
|
||||
wallpapers = list(
|
||||
filter(
|
||||
lambda x: x.suffix in self.image_extensions,
|
||||
self.wallpapers_dir.iterdir(),
|
||||
)
|
||||
)
|
||||
random.shuffle(wallpapers)
|
||||
self.current_wallpaper_list = wallpapers
|
||||
self.current_wallpaper_index = 0
|
||||
|
||||
def set_wallpaper(self, path: Path):
|
||||
# check if we are running under x11 or wayland
|
||||
if (
|
||||
"WAYLAND_DISPLAY" in os.environ
|
||||
or os.environ.get("XDG_SESSION_TYPE") == "wayland"
|
||||
):
|
||||
self.set_wallpaper_wayland(path)
|
||||
else:
|
||||
self.set_wallpaper_x11(path)
|
||||
|
||||
def set_wallpaper_x11(self, path: Path):
|
||||
subprocess.run(["feh", "--bg-fill", path])
|
||||
|
||||
def set_wallpaper_wayland(self, path: Path):
|
||||
# find all swaybg processes
|
||||
swaybg_pids = subprocess.run(
|
||||
["pgrep", "-f", "swaybg"], stdout=subprocess.PIPE
|
||||
).stdout.decode("utf-8")
|
||||
|
||||
# run swaybg in the background, and make it running even after the parent process exits
|
||||
subprocess.Popen(
|
||||
["swaybg", "--output", "*", "--mode", "fill", "--image", path],
|
||||
start_new_session=True,
|
||||
)
|
||||
time.sleep(1)
|
||||
|
||||
# kill all old swaybg processes
|
||||
for pid in swaybg_pids.splitlines():
|
||||
try:
|
||||
os.kill(int(pid), 9)
|
||||
except ProcessLookupError:
|
||||
pass
|
||||
|
||||
|
||||
def main():
|
||||
wallpapers_dir = os.getenv("WALLPAPERS_DIR")
|
||||
state_filepath = os.getenv("WALLPAPERS_STATE_FILEPATH")
|
||||
if not wallpapers_dir:
|
||||
raise Exception("WALLPAPERS_DIR not set")
|
||||
if not state_filepath:
|
||||
raise Exception("WALLPAPERS_STATE_FILEPATH not set")
|
||||
|
||||
image_postfix = (
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".png",
|
||||
# ".gif",
|
||||
# ".webp"
|
||||
)
|
||||
wait_min = int(os.getenv("WALLPAPER_WAIT_MIN", 60))
|
||||
wait_max = int(os.getenv("WALLPAPER_WAIT_MAX", 300))
|
||||
wallpaper_switcher = WallpaperSwitcher(
|
||||
wait_min,
|
||||
wait_max,
|
||||
Path(wallpapers_dir).expanduser(),
|
||||
Path(state_filepath).expanduser(),
|
||||
image_postfix,
|
||||
)
|
||||
wallpaper_switcher.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -12,9 +12,14 @@
|
||||
xdg-user-dirs
|
||||
];
|
||||
|
||||
xdg.configFile."mimeapps.list".force = true;
|
||||
xdg = {
|
||||
enable = true;
|
||||
cacheHome = config.home.homeDirectory + "/.local/cache";
|
||||
|
||||
cacheHome = "${config.home.homeDirectory}/.cache";
|
||||
configHome = "${config.home.homeDirectory}/.config";
|
||||
dataHome = "${config.home.homeDirectory}/.local/share";
|
||||
stateHome = "${config.home.homeDirectory}/.local/state";
|
||||
|
||||
# manage $XDG_CONFIG_HOME/mimeapps.list
|
||||
# xdg search all desktop entries from $XDG_DATA_DIRS, check it by command:
|
||||
@@ -51,7 +56,7 @@
|
||||
"x-scheme-handler/unknown" = browser;
|
||||
|
||||
"x-scheme-handler/discord" = ["discord.desktop"];
|
||||
"x-scheme-handler/tg" = ["telegramdesktop.desktop"];
|
||||
"x-scheme-handler/tg" = ["org.telegram.desktop.desktop "];
|
||||
|
||||
"audio/*" = ["mpv.desktop"];
|
||||
"video/*" = ["mpv.dekstop"];
|
||||
@@ -1,37 +1,3 @@
|
||||
{pkgs, ...}: {
|
||||
imports = [
|
||||
./creative.nix
|
||||
./gtk.nix
|
||||
./immutable-file.nix
|
||||
./media.nix
|
||||
./ssh.nix
|
||||
./wallpaper.nix
|
||||
./xdg.nix
|
||||
./eye-protection.nix
|
||||
];
|
||||
|
||||
home.packages = with pkgs; [
|
||||
# GUI apps
|
||||
# e-book viewer(.epub/.mobi/...)
|
||||
# do not support .pdf
|
||||
foliate
|
||||
|
||||
# instant messaging
|
||||
telegram-desktop
|
||||
discord
|
||||
qq # https://github.com/NixOS/nixpkgs/tree/master/pkgs/applications/networking/instant-messengers/qq
|
||||
|
||||
# remote desktop(rdp connect)
|
||||
remmina
|
||||
freerdp # required by remmina
|
||||
|
||||
# misc
|
||||
flameshot
|
||||
ventoy # multi-boot usb creator
|
||||
];
|
||||
|
||||
# GitHub CLI tool
|
||||
programs.gh = {
|
||||
enable = true;
|
||||
};
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
## Hyprland configuration file
|
||||
|
||||
# color-scheme: cappuccin-mocha
|
||||
source=~/.config/hypr/themes/mocha.conf
|
||||
|
||||
env = _JAVA_AWT_WM_NONREPARENTING,1
|
||||
env = QT_WAYLAND_DISABLE_WINDOWDECORATION,1
|
||||
# fix https://github.com/hyprwm/Hyprland/issues/1520
|
||||
env = WLR_NO_HARDWARE_CURSORS,1
|
||||
|
||||
#-- Output ----------------------------------------------------
|
||||
# Configure your Display resolution, offset, scale and Monitors here, use `hyprctl monitors` to get the info.
|
||||
|
||||
# format:
|
||||
# monitor=name,resolution,position,scale
|
||||
monitor=DP-2,3840x2160@144,0x0,1.6
|
||||
workspace=DP-2,1
|
||||
|
||||
#-- Input ----------------------------------------------------
|
||||
# Configure mouse and touchpad here.
|
||||
input {
|
||||
@@ -199,10 +181,9 @@ bind=SUPER,mouse_up,workspace,e-1
|
||||
#-- Startup ----------------------------------------------------
|
||||
exec-once=~/.config/hypr/scripts/startup
|
||||
|
||||
|
||||
#-- Fcitx5 input method ----------------------------------------------------
|
||||
# -- Fcitx5 input method
|
||||
windowrule=pseudo,fcitx # enable this will make fcitx5 works, but fcitx5-configtool will not work!
|
||||
exec-once=cp ~/.config/fcitx5/profile-bak ~/.config/fcitx5/profile # restore fcitx5 profile manged by nixos
|
||||
exec-once=cp ~/.config/fcitx5/profile-bak ~/.config/fcitx5/profile # restore fcitx5 profile managed by nixos
|
||||
exec-once=fcitx5 -d --replace # start fcitx5 daemon
|
||||
bind=ALT,E,exec,pkill fcitx5 -9;sleep 1;fcitx5 -d --replace; sleep 1;fcitx5-remote -r
|
||||
|
||||
@@ -211,22 +192,3 @@ windowrulev2 = rounding 0, xwayland:1, floating:1
|
||||
windowrulev2 = center, class:^(.*jetbrains.*)$, title:^(Confirm Exit|Open Project|win424|win201|splash)$
|
||||
windowrulev2 = size 640 400, class:^(.*jetbrains.*)$, title:^(splash)$
|
||||
|
||||
# -- Fix input method in vscode
|
||||
exec-once = hyprctl setcursor "Bibata-Modern-Ice" 24
|
||||
# 效果是 wayland 原生窗口缩放完全正常
|
||||
# xwayland 窗口先渲染到 200% 再降到 hyprland config 里 monitor 设置的值,看上去和原生没啥区别
|
||||
# 相比较一开始的方案输入法字体大小也正确了.唯一有点问题的可能是 xwayland 窗口下的鼠标指针大小不对
|
||||
exec-once = xprop -root -f _XWAYLAND_GLOBAL_OUTPUT_SCALE 32c -set _XWAYLAND_GLOBAL_OUTPUT_SCALE 2
|
||||
|
||||
-- Fix HiDPI - xwayland
|
||||
# change monitor to high resolution, the last argument is the scale factor
|
||||
monitor=,highres,auto,2
|
||||
|
||||
# unscale XWayland
|
||||
xwayland {
|
||||
force_zero_scaling = true
|
||||
}
|
||||
|
||||
# toolkit-specific scale
|
||||
env = GDK_SCALE,2
|
||||
env = XCURSOR_SIZE,32
|
||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
@@ -10,8 +10,9 @@ for _prs in "${_ps[@]}"; do
|
||||
fi
|
||||
done
|
||||
|
||||
# Set wallpaper
|
||||
swaybg --output '*' --mode fill --image ~/.config/wallpapers/default_wallpaper &
|
||||
# Set wallpaper via a wallpaper.service
|
||||
# it will by start by home-manager automatically, do not need to restart it here.
|
||||
# systemctl --user restart wallpaper.service
|
||||
|
||||
# Lauch notification daemon (mako)
|
||||
~/.config/hypr/scripts/notifications &
|
||||
|
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.4 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
@@ -0,0 +1,47 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
anyrun,
|
||||
...
|
||||
} @ args:
|
||||
with lib; let
|
||||
cfg = config.modules.desktop.hyprland;
|
||||
in {
|
||||
imports = [
|
||||
anyrun.homeManagerModules.default
|
||||
./options
|
||||
];
|
||||
|
||||
options.modules.desktop.hyprland = {
|
||||
enable = mkEnableOption "hyprland compositor";
|
||||
settings = lib.mkOption {
|
||||
type = with lib.types; let
|
||||
valueType =
|
||||
nullOr (oneOf [
|
||||
bool
|
||||
int
|
||||
float
|
||||
str
|
||||
path
|
||||
(attrsOf valueType)
|
||||
(listOf valueType)
|
||||
])
|
||||
// {
|
||||
description = "Hyprland configuration value";
|
||||
};
|
||||
in
|
||||
valueType;
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (
|
||||
mkMerge ([
|
||||
{
|
||||
wayland.windowManager.hyprland.settings = cfg.settings;
|
||||
}
|
||||
]
|
||||
++ (import ./values args))
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{mylib, ...}: {
|
||||
imports = mylib.scanPaths ./.;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.modules.desktop.hyprland;
|
||||
in {
|
||||
options.modules.desktop.hyprland = {
|
||||
nvidia = mkEnableOption "whether nvidia GPU is used";
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable && cfg.nvidia) {
|
||||
wayland.windowManager.hyprland.settings.env = [
|
||||
# for hyprland with nvidia gpu, ref https://wiki.hyprland.org/Nvidia/
|
||||
"LIBVA_DRIVER_NAME,nvidia"
|
||||
"XDG_SESSION_TYPE,wayland"
|
||||
"GBM_BACKEND,nvidia-drm"
|
||||
"__GLX_VENDOR_LIBRARY_NAME,nvidia"
|
||||
# fix https://github.com/hyprwm/Hyprland/issues/1520
|
||||
"WLR_NO_HARDWARE_CURSORS,1"
|
||||
];
|
||||
};
|
||||
}
|
||||
@@ -3,10 +3,6 @@
|
||||
anyrun,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
anyrun.homeManagerModules.default
|
||||
];
|
||||
|
||||
programs.anyrun = {
|
||||
enable = true;
|
||||
config = {
|
||||
@@ -0,0 +1,4 @@
|
||||
{mylib, ...} @ args:
|
||||
map
|
||||
(path: import path args)
|
||||
(mylib.scanPaths ./.)
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
hyprland,
|
||||
nur-ryan4yin,
|
||||
...
|
||||
}: {
|
||||
# NOTE:
|
||||
# We have to enable hyprland/i3's systemd user service in home-manager,
|
||||
# so that gammastep/wallpaper-switcher's user service can be start correctly!
|
||||
# they are all depending on hyprland/i3's user graphical-session
|
||||
wayland.windowManager.hyprland = {
|
||||
enable = true;
|
||||
settings = {
|
||||
source = "${nur-ryan4yin.packages.${pkgs.system}.catppuccin-hyprland}/themes/mocha.conf";
|
||||
env = [
|
||||
"NIXOS_OZONE_WL,1" # for any ozone-based browser & electron apps to run on wayland
|
||||
"MOZ_ENABLE_WAYLAND,1" # for firefox to run on wayland
|
||||
"MOZ_WEBRENDER,1"
|
||||
# misc
|
||||
"_JAVA_AWT_WM_NONREPARENTING,1"
|
||||
"QT_WAYLAND_DISABLE_WINDOWDECORATION,1"
|
||||
];
|
||||
};
|
||||
package = hyprland.packages.${pkgs.system}.hyprland;
|
||||
extraConfig = builtins.readFile ../conf/hyprland.conf;
|
||||
# gammastep/wallpaper-switcher need this to be enabled.
|
||||
systemd.enable = true;
|
||||
};
|
||||
|
||||
# NOTE: this executable is used by greetd to start a wayland session when system boot up
|
||||
# with such a vendor-no-locking script, we can switch to another wayland compositor without modifying greetd's config in NixOS module
|
||||
home.file.".wayland-session" = {
|
||||
source = "${pkgs.hyprland}/bin/Hyprland";
|
||||
executable = true;
|
||||
};
|
||||
|
||||
# hyprland configs, based on https://github.com/notwidow/hyprland
|
||||
xdg.configFile = {
|
||||
"hypr/mako" = {
|
||||
source = ../conf/mako;
|
||||
recursive = true;
|
||||
};
|
||||
"hypr/scripts" = {
|
||||
source = ../conf/scripts;
|
||||
recursive = true;
|
||||
};
|
||||
"hypr/waybar" = {
|
||||
source = ../conf/waybar;
|
||||
recursive = true;
|
||||
};
|
||||
"hypr/wlogout" = {
|
||||
source = ../conf/wlogout;
|
||||
recursive = true;
|
||||
};
|
||||
|
||||
# music player - mpd
|
||||
"mpd" = {
|
||||
source = ../conf/mpd;
|
||||
recursive = true;
|
||||
};
|
||||
};
|
||||
|
||||
# allow fontconfig to discover fonts and configurations installed through home.packages
|
||||
fonts.fontconfig.enable = true;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{pkgs, ...}: {
|
||||
home.packages = with pkgs; [
|
||||
waybar # the status bar
|
||||
swaybg # the wallpaper
|
||||
swayidle # the idle timeout
|
||||
swaylock # locking the screen
|
||||
wlogout # logout menu
|
||||
wl-clipboard # copying and pasting
|
||||
hyprpicker # color picker
|
||||
|
||||
wf-recorder # creen recording
|
||||
grim # taking screenshots
|
||||
slurp # selecting a region to screenshot
|
||||
# TODO replace by `flameshot gui --raw | wl-copy`
|
||||
|
||||
mako # the notification daemon, the same as dunst
|
||||
|
||||
yad # a fork of zenity, for creating dialogs
|
||||
|
||||
# audio
|
||||
alsa-utils # provides amixer/alsamixer/...
|
||||
mpd # for playing system sounds
|
||||
mpc-cli # command-line mpd client
|
||||
ncmpcpp # a mpd client with a UI
|
||||
networkmanagerapplet # provide GUI app: nm-connection-editor
|
||||
];
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
commandLineArgs = [
|
||||
# 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=5"
|
||||
"--gtk-version=4"
|
||||
"--enable-features=UseOzonePlatform"
|
||||
"--ozone-platform=wayland"
|
||||
# make it use text-input-v1, which works for kwin 5.27 and weston
|
||||
@@ -0,0 +1 @@
|
||||
i3-msg exit
|
||||
@@ -261,8 +261,7 @@ exec --no-startup-id dex --autostart --environment i3
|
||||
exec --no-startup-id ~/.screenlayout/monitor.sh
|
||||
|
||||
# set wallpaper
|
||||
# exec --no-startup-id sleep 2 && nitrogen --restore
|
||||
exec --no-startup-id sleep 1 && feh --bg-fill ~/.config/wallpapers/default_wallpaper
|
||||
exec --no-startup-id sleep 1 && systemctl --user restart wallpaper.service
|
||||
|
||||
# set powersavings for display:
|
||||
exec --no-startup-id xset s 480 dpms 600 600 600
|
||||