diff --git a/Droidnix/README.html b/Droidnix/README.html index 1cf636b99..158e4c8bb 100644 --- a/Droidnix/README.html +++ b/Droidnix/README.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + Droidnix: A Dendritic NixOS + Home Manager Configuration NixOS Configuration Structure @@ -204,114 +204,114 @@

Table of Contents

-
-

Shortcuts

-
+
+

Shortcuts

+

Introduction The Assets Folder @@ -327,26 +327,26 @@

Introduction   intro

-
-

What is Droidnix

-
+
+

What is Droidnix

+

Droidnix is a modular, declarative NixOS + Home Manager configuration system. It allows users to choose between Hyprland and Mangowc as their window manager, with shared and WM-specific configurations managed via Emacs Org and Nix Flakes. The project is designed for reproducibility, maintainability, and cross-machine compatibility.

-
-

Installed components:

-
+
+

Installed components:

+
    -
  • Core
  • -
  • Hyprland
  • -
  • Mangowc
  • +
  • Core
  • +
  • Hyprland
  • +
  • Mangowc
-
-

Goals, project Structure, import hierarchy

-
+
+

Goals, project Structure, import hierarchy

+

This project uses a modular NixOS configuration with Hyprland and MangoWC support, designed for literate programming and cross-device reusability. The Droidnix repository is organized into two main parts: @@ -359,9 +359,9 @@ The Droidnix repository is organized into two main parts:

-
-

Root Level

-
+
+

Root Level

+
  • flake.nix is the entry point and imports:
      @@ -372,16 +372,16 @@ The Droidnix repository is organized into two main parts:
-
-

Generated Structure

-
+
+

Generated Structure

+

The generated/ directory contains all generated configurations, divided into three main groups: system, hyprland, and mangowc.

-
-

First Setup

-
+
+

First Setup

+
  1. Clone this repository.
  2. Run the setup script: ./setup_droid.
  3. @@ -411,9 +411,9 @@ The .assets/ folder contains all static files, such as configs, scr This section contains the Org blocks for tangling Nix code into the generated folders.

-
-

flake.nix

-
+
+

flake.nix

+

The Nix flake definition for Droidnix.

@@ -478,9 +478,9 @@ The Nix flake definition for Droidnix.
-
-

generated/hosts/traveldroid/host.nix

-
+
+

generated/hosts/traveldroid/host.nix

+
{ lib, config, pkgs, flakeRoot, import-tree, home-manager, ... }:
 
@@ -536,9 +536,9 @@ in
 
-
-

generated/hosts/traveldroid/hardware-configuration.nix

-
+
+

generated/hosts/traveldroid/hardware-configuration.nix

+
  1. Boot into NixOS Live ISO or your installed system.
  2. Open a terminal.
  3. @@ -596,9 +596,9 @@ in
-
-

generated/hosts/traveldroid/boot.nix

-
+
+

generated/hosts/traveldroid/boot.nix

+
{ config, pkgs, lib, flakeRoot, ... }:
 
@@ -650,17 +650,17 @@ in
 
-
-

Following are the imported modules

+
+

Following are the imported modules

-
-

generated/traveldroid/modules/apps

-
+
+

generated/traveldroid/modules/apps

+
-
-

generated/modules/traveldroid/apps/packages.nix

-
+
+

generated/modules/traveldroid/apps/packages.nix

+

This installs a list of apps

@@ -724,9 +724,9 @@ in {
-
-

generated/assets/packages.conf

-
+
+

generated/assets/packages.conf

+

This is a list of additional apps to install

@@ -787,9 +787,9 @@ vlc
-
-

generated/modules/traveldroid/apps/kitty.nix

-
+
+

generated/modules/traveldroid/apps/kitty.nix

+

This file sets up Kitty terminal

@@ -851,9 +851,9 @@ in
-
-

.config/kitty/Catppuccin-Mocha.conf

-
+
+

.config/kitty/Catppuccin-Mocha.conf

+

These are config files for .config/kitty

@@ -944,9 +944,9 @@ color15 #a6adc8
-
-

.config/kitty/kitty.conf

-
+
+

.config/kitty/kitty.conf

+

These are config files for .config/kitty

@@ -968,9 +968,9 @@ font_size 10.0
-
-

generated/modules/traveldroid/apps/starship.nix

-
+
+

generated/modules/traveldroid/apps/starship.nix

+

This file sets up starship prompt

@@ -1010,9 +1010,9 @@ in
-
-

.config/starship.toml

-
+
+

.config/starship.toml

+

These are config files for .config

@@ -1301,9 +1301,9 @@ crust = "#181926"
-
-

generated/modules/traveldroid/apps/thunar.nix

-
+
+

generated/modules/traveldroid/apps/thunar.nix

+

This is top file of this level which contains just an import statement for all relevant files and/or the subfolder in this folder

@@ -1343,9 +1343,9 @@ in
-
-

generated/modules/traveldroid/apps/wofi.nix

-
+
+

generated/modules/traveldroid/apps/wofi.nix

+

This is the install for Wofi, the launcher

@@ -1378,9 +1378,9 @@ in
-
-

.config/wofi/config

-
+
+

.config/wofi/config

+

These are config files for .config/wofi

@@ -1427,9 +1427,9 @@ prompt = >
-
-

.config/wofi/style.css

-
+
+

.config/wofi/style.css

+

These are config files for .config/wofi

@@ -1518,9 +1518,9 @@ These are config files for .config/wofi
-
-

generated/modules/traveldroid/apps/zenbrowser.nix

-
+
+

generated/modules/traveldroid/apps/zenbrowser.nix

+

This installs zen browser

@@ -1540,9 +1540,9 @@ in
-
-

generated/modules/traveldroid/apps/zsh.nix

-
+
+

generated/modules/traveldroid/apps/zsh.nix

+

This sets up the zsh in the terminal

@@ -1598,9 +1598,9 @@ in
-
-

=generated/.config/zsh/.zshrc

-
+
+

=generated/.config/zsh/.zshrc

+

This sets up the zsh in the terminal

@@ -1635,9 +1635,9 @@ fi
-
-

generated/modules/traveldroid/apps/emacs/emacs.nix

-
+
+

generated/modules/traveldroid/apps/emacs/emacs.nix

+

This installs emacs

@@ -1733,9 +1733,9 @@ in
-
-

generated/.config/emacs/early-init.el

-
+
+

generated/.config/emacs/early-init.el

+

This contaions emacs

@@ -1836,9 +1836,9 @@ package-archive-priorities '(("gnu" . 99)
-
-

generated/.config/emacs/init.el

-
+
+

generated/.config/emacs/init.el

+

This contaions emacs

@@ -2249,13 +2249,13 @@ the top of the file."
-
-

generated/modules/traveldroid/desktop

-
+
+

generated/modules/traveldroid/desktop

+
-
-

generated/modules/traveldroid/desktop/fonts.nix

-
+
+

generated/modules/traveldroid/desktop/fonts.nix

+

This file installs and configures fonts

@@ -2273,9 +2273,9 @@ This file installs and configures fonts
-
-

generated/modules/traveldroid/desktop/gtk.nix

-
+
+

generated/modules/traveldroid/desktop/gtk.nix

+

Setting up GTK

@@ -2301,9 +2301,9 @@ in
-
-

generated/modules/traveldroid/desktop/hyprland.nix

-
+
+

generated/modules/traveldroid/desktop/hyprland.nix

+

Setting up Hyprland

@@ -2350,9 +2350,9 @@ in
-
-

.config/hypr/animations.conf

-
+
+

.config/hypr/animations.conf

+

These are config files for .config/hypr

@@ -2373,9 +2373,9 @@ animations {
-
-

.config/hypr/behaviour.conf

-
+
+

.config/hypr/behaviour.conf

+

These are config files for .config/hypr

@@ -2417,9 +2417,9 @@ misc {
-
-

.config/hypr/bindings.conf

-
+
+

.config/hypr/bindings.conf

+

These are config files for .config/hypr

@@ -2582,9 +2582,9 @@ bind = $mainMod, W, exec, zen
-
-

.config/hypr/exec-once.conf

-
+
+

.config/hypr/exec-once.conf

+

These are config files for .config/hypr

@@ -2598,9 +2598,9 @@ exec-once = bash -c "sleep 5 && waybar"
-
-

.config/hypr/hypridle.conf

-
+
+

.config/hypr/hypridle.conf

+

These are config files for .config/hypr

@@ -2625,9 +2625,9 @@ listener {
-
-

.config/hypr/hyprland.conf

-
+
+

.config/hypr/hyprland.conf

+

These are config files for .config/hypr

@@ -2641,7 +2641,7 @@ source = ./layer-rules.conf source = ./layout.conf source = ./monitor-rules.conf # source = ./window-rules.conf -# source = ./workspace-rules.conf +source = ./workspace-rules.conf exec-once = /nix/store/c9cnbxhxbagj7gfpc1g5hl4x4f8dzayv-dbus-1.16.2/bin/dbus-update-activation-environment --systemd DISPLAY HYPRLAND_INSTANCE_SIGNATURE WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_TYPE && systemctl --user stop hyprland-session.target && systemctl --user start hyprland-session.target @@ -2674,9 +2674,9 @@ misc {
-
-

.config/hypr/hyprlock.conf

-
+
+

.config/hypr/hyprlock.conf

+

These are config files for .config/hypr

@@ -2717,9 +2717,9 @@ label {
-
-

.config/hypr/layer-rules.conf

-
+
+

.config/hypr/layer-rules.conf

+

These are config files for .config/hypr

@@ -2734,9 +2734,9 @@ layerrule = blur on, ignore_alpha 1, match:namespace swaync-notification-window
-
-

.config/hypr/layout.conf

-
+
+

.config/hypr/layout.conf

+

These are config files for .config/hypr

@@ -2746,9 +2746,9 @@ These are config files for .config/hypr
-
-

.config/hypr/monitor-rules.conf

-
+
+

.config/hypr/monitor-rules.conf

+

These are config files for .config/hypr

@@ -2759,9 +2759,9 @@ monitor=DP-1,3840x1080@144,1920x0,1
-
-

.config/hypr/scripts/layout-selector.sh

-
+
+

.config/hypr/scripts/layout-selector.sh

+

These are config files for .config/hypr/scripts

@@ -2804,9 +2804,9 @@ hyprctl dispatch oSD "Layout: $LAYOUT_NAME" 2000
-
-

.config/hypr/theming.css

-
+
+

.config/hypr/theming.css

+

These are config files for .config/hypr

@@ -2855,9 +2855,9 @@ decoration {
-
-

.config/hypr/window-rules.conf

-
+
+

.config/hypr/window-rules.conf

+

These are config files for .config/hypr

@@ -2881,20 +2881,27 @@ windowrulev2 = floatclass:Wofi,opacity:0.9,blur:15
-
-

.config/hypr/workspace-rules.conf

-
+
+

.config/hypr/workspace-rules.conf

+

These are config files for .config/hypr

-
# Workspace definitions (modern syntax)
+
+#Load random wallpaper
+workspacecreated = exec $HOME/.local/bin/wallpaper-sync-and-set.sh $workspace
+
+/*
+
+# Workspace definitions (modern syntax)
 workspace = 1
 workspace = 2
 workspace = 3
 workspace = 4
 workspace = 5
 
+/*
 # Auto-launch apps on specific workspaces (use `exec` with `workspace` rule)
 exec-once = kitty, workspace 1
 exec-once = flatpak run app.betterbird.zen, workspace 2
@@ -2918,91 +2925,31 @@ windowrule = move workspace 3, ^(libreoffice)$
 workspace {
     cycle_move_empty = no
 }
+
+*/
 
-
-

generated/modules/traveldroid/desktop/wallpaper.nix

-
+
+

generated/modules/traveldroid/desktop/wallpaper.nix

+

Setting up wallpaper engine + wallpaper gui

-
{ config, pkgs, lib, flakeRoot, ... }:
+
{ config, pkgs, lib, ... }:
 
 let
-  username     = config.defaultUser or "henrov";
-  homeDir      = "/home/${username}";
-  wallpaperSrc = "${flakeRoot}/assets/Wallpapers";
-  wallpaperDst = "${homeDir}/Wallpapers";
-
-  script = pkgs.writeShellScript "wallpaper-sync-and-set.sh" ''
-    #!/usr/bin/env bash
-    set -euo pipefail
-
-    SRC="${wallpaperSrc}"
-    DST="${wallpaperDst}"
-
-    mkdir -p "$SRC" "$DST"
-
-    ########################################
-    # 2-way sync (additive, newer wins)
-    ########################################
-
-    # SRC -> DST
-    rsync -au "$SRC/" "$DST/"
-
-    # DST -> SRC
-    rsync -au "$DST/" "$SRC/"
-
-    ########################################
-    # Initialize swww (safe if already running)
-    ########################################
-    if ! pgrep -x swww-daemon >/dev/null; then
-      swww init
-      sleep 1
-    fi
-
-    ########################################
-    # Get workspaces
-    ########################################
-    WORKSPACES=$(hyprctl workspaces -j | jq -r '.[].id')
-
-    ########################################
-    # Function: set random wallpaper for workspace
-    ########################################
-    set_wallpaper() {
-      local WS="$1"
-
-      WALL=$(find "$DST" -type f | shuf -n 1)
-
-      if [ -n "$WALL" ]; then
-        hyprctl dispatch workspace "$WS"
-        swww img "$WALL" --transition-type any
-      fi
-    }
-
-    ########################################
-    # If workspace passed → only update that
-    ########################################
-    if [ "$#" -eq 1 ]; then
-      set_wallpaper "$1"
-      exit 0
-    fi
-
-    ########################################
-    # Otherwise: update all workspaces
-    ########################################
-    for WS in $WORKSPACES; do
-      set_wallpaper "$WS"
-    done
-  '';
+  username = config.defaultUser or "henrov";
+  homeDir  = "/home/${username}";
+  wallpaperDir = "${homeDir}/Wallpapers";
+  scriptDest  = "${homeDir}/Wallpapers/wallpaper-sync-and-set.sh";
 in
 {
-  #################################
-  # Packages
-  #################################
+  ############################
+  # Systemwide packages
+  ############################
   environment.systemPackages = with pkgs; [
     swww
     waypaper
@@ -3010,56 +2957,46 @@ in
     rsync
   ];
 
-  #################################
-  # Service: main worker
-  #################################
+  ############################
+  # Install the script
+  ############################
+  home.file."Wallpapers/wallpaper-sync-and-set.sh".source = ./assets/Wallpapers/wallpaper-sync-and-set.sh;
+  home.file."Wallpapers/wallpaper-sync-and-set.sh".executable = true;
+
+  ############################
+  # Systemd user service + timer
+  ############################
   systemd.user.services.wallpaperSync = {
     description = "2-way sync wallpapers + set random per workspace";
-    after = [ "graphical-session.target" ];
-
-    serviceConfig = {
-      Type = "oneshot";
-      ExecStart = "${script}";
-    };
-
-    wantedBy = [ "default.target" ]; # run at login
+    serviceConfig.Type = "oneshot";
+    serviceConfig.ExecStart = "${scriptDest}";
+    serviceConfig.Restart = "on-failure";
   };
 
-  #################################
-  # Timer: every hour
-  #################################
-  systemd.user.timers.wallpaperSync = {
-    description = "Run wallpaper sync hourly";
-
+  systemd.user.timers.wallpaperSyncTimer = {
+    description = "Run wallpaper sync every hour";
     wantedBy = [ "timers.target" ];
-
-    timerConfig = {
-      OnBootSec = "2min";
-      OnUnitActiveSec = "1h";
-      Persistent = true;
-    };
+    timerConfig.OnCalendar = "hourly";
+    timerConfig.Persistent = true;
   };
 
-  #################################
-  # Hyprland integration (new workspace)
-  #################################
-  # This assumes you manage Hyprland via Nix/Home Manager
-  #################################
-  environment.etc."hypr/hyprland.conf".text = lib.mkAfter ''
-    # Run wallpaper script when workspace changes
-    bind = SUPER, Return, exec, ${script}
-
-    # Hook: when workspace is created/switched
-    exec-once = hyprctl --batch "dispatch exec ${script}"
-  '';
+  ############################
+  # Run at login
+  ############################
+  systemd.user.services.wallpaperSyncLogin = {
+    description = "Run wallpaper sync at login";
+    serviceConfig.Type = "oneshot";
+    serviceConfig.ExecStart = "${scriptDest}";
+    install.WantedBy = [ "default.target" ];
+  };
 }
 
-
-

generated/modules/traveldroid/desktop/stylix.nix

-
+
+

generated/modules/traveldroid/desktop/stylix.nix

+
{ lib, config, pkgs, flakeRoot, stylix, ... }:
 
@@ -3151,9 +3088,9 @@ in
 
-
-

.config/stylix/stylix.conf

-
+
+

.config/stylix/stylix.conf

+

These are config files for .config/stylix

@@ -3190,9 +3127,9 @@ icons = {
-
-

.config/stylix/palette.json

-
+
+

.config/stylix/palette.json

+

These are config files for .config/stylix

@@ -3222,9 +3159,9 @@ These are config files for .config/stylix
-
-

.config/stylix/palette.html

-
+
+

.config/stylix/palette.html

+

These are config files for .config/stylix

@@ -3302,9 +3239,9 @@ These are config files for .config/stylix
-
-

generated/modules/traveldroid/desktop/waybar.nix

-
+
+

generated/modules/traveldroid/desktop/waybar.nix

+

This file installs and configures waybar

@@ -3355,9 +3292,9 @@ in
-
-

.config/waybar/config

-
+
+

.config/waybar/config

+

These are config files for waybar

@@ -3480,9 +3417,9 @@ These are config files for waybar
-
-

.config/waybar/style.css

-
+
+

.config/waybar/style.css

+

These are config files for waybar

@@ -3717,9 +3654,9 @@ window#waybar {
-
-

.config/waypaper/config.ini

-
+
+

.config/waypaper/config.ini

+

These are config files for waypaper

@@ -3756,9 +3693,9 @@ keybindings = ~/.config/waypaper/keybindings.ini
-
-

generated/modules/traveldroid/desktop/wayland.nix

-
+
+

generated/modules/traveldroid/desktop/wayland.nix

+
{ lib, config, pkgs, ... }:
 
@@ -3788,9 +3725,9 @@ keybindings = ~/.config/waypaper/keybindings.ini
 
-
-

generated/modules/traveldroid/desktop/xdg.nix

-
+
+

generated/modules/traveldroid/desktop/xdg.nix

+

This sets the XDG implementation

@@ -3843,13 +3780,13 @@ in
-
-

generated/modules/traveldroid/system

-
+
+

generated/modules/traveldroid/system

+
-
-

generated/modules/traveldroid/system/bluetooth.nix

-
+
+

generated/modules/traveldroid/system/bluetooth.nix

+
{ lib, config, pkgs, flakeRoot, home-manager, ... }:
 
@@ -3890,9 +3827,9 @@ in
 
-
-

generated/modules/traveldroid/system/dbus.nix

-
+
+

generated/modules/traveldroid/system/dbus.nix

+

This sets the dbus implementation

@@ -3919,9 +3856,9 @@ This sets the dbus implementation
-
-

generated/modules/traveldroid/system/login-tuigreet.nix

-
+
+

generated/modules/traveldroid/system/login-tuigreet.nix

+

This sets up tuigreeter which is not fancy but imo fits the aesthetic I am aiming for

@@ -3975,9 +3912,9 @@ in
-
-

generated/modules/traveldroid/system/networking.nix

-
+
+

generated/modules/traveldroid/system/networking.nix

+

This sets the networking.

@@ -4041,9 +3978,9 @@ This sets the networking.
-
-

generated/modules/traveldroid/system/nix.nix

-
+
+

generated/modules/traveldroid/system/nix.nix

+
{ lib, config, ... }:
 
@@ -4060,13 +3997,13 @@ This sets the networking.
 
-
-

generated/users

-
+
+

generated/users

+
-
-

generated/parked/users/copy_config_2_config.nix

-
+
+

generated/parked/users/copy_config_2_config.nix

+

This copies stuff to the user home-folder

@@ -4117,9 +4054,9 @@ in
-
-

generated/users/henrov.nix

-
+
+

generated/users/henrov.nix

+

This is the default user, just search and replace henrov another name if you want to change

@@ -4174,9 +4111,9 @@ in

These are all the prepared config files

-
-

.config/waybar/style.css

-
+
+

.config/waybar/style.css

+

These are config files for .config/waybar

@@ -4410,9 +4347,9 @@ window#waybar {
-
-

.config/waypaper/config.ini

-
+
+

.config/waypaper/config.ini

+

These are config files for .config/waypaper

@@ -4449,9 +4386,9 @@ keybindings = ~/.config/waypaper/keybindings.ini
-
-

.config/zed/settings.json

-
+
+

.config/zed/settings.json

+

These are config files for .config/zed

@@ -4491,7 +4428,7 @@ These are config files for .config/zed

Author: Henro Veijer

-

Created: 2026-03-29 Sun 11:48

+

Created: 2026-03-29 Sun 12:05

Validate

diff --git a/Droidnix/README.org b/Droidnix/README.org index 721531425..00550cf85 100644 --- a/Droidnix/README.org +++ b/Droidnix/README.org @@ -2115,7 +2115,7 @@ source = ./layer-rules.conf source = ./layout.conf source = ./monitor-rules.conf # source = ./window-rules.conf -# source = ./workspace-rules.conf +source = ./workspace-rules.conf exec-once = /nix/store/c9cnbxhxbagj7gfpc1g5hl4x4f8dzayv-dbus-1.16.2/bin/dbus-update-activation-environment --systemd DISPLAY HYPRLAND_INSTANCE_SIGNATURE WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_TYPE && systemctl --user stop hyprland-session.target && systemctl --user start hyprland-session.target @@ -2314,6 +2314,12 @@ windowrulev2 = floatclass:Wofi,opacity:0.9,blur:15 ** =.config/hypr/workspace-rules.conf= These are config files for .config/hypr #+BEGIN_SRC conf :tangle generated/.config/hypr/workspace-rules.conf :noweb yes :mkdirp yes :eval never + +#Load random wallpaper +workspacecreated = exec $HOME/.local/bin/wallpaper-sync-and-set.sh $workspace + +/* + # Workspace definitions (modern syntax) workspace = 1 workspace = 2 @@ -2321,6 +2327,7 @@ workspace = 3 workspace = 4 workspace = 5 +/* # Auto-launch apps on specific workspaces (use `exec` with `workspace` rule) exec-once = kitty, workspace 1 exec-once = flatpak run app.betterbird.zen, workspace 2 @@ -2344,85 +2351,25 @@ windowrule = move workspace 3, ^(libreoffice)$ workspace { cycle_move_empty = no } + +*/ #+END_SRC ** =generated/modules/traveldroid/desktop/wallpaper.nix= Setting up wallpaper engine + wallpaper gui #+BEGIN_SRC nix :tangle generated/modules/traveldroid/desktop/wallpaper.nix :noweb yes :mkdirp yes :eval never -{ config, pkgs, lib, flakeRoot, ... }: +{ config, pkgs, lib, ... }: let - username = config.defaultUser or "henrov"; - homeDir = "/home/${username}"; - wallpaperSrc = "${flakeRoot}/assets/Wallpapers"; - wallpaperDst = "${homeDir}/Wallpapers"; - - script = pkgs.writeShellScript "wallpaper-sync-and-set.sh" '' - #!/usr/bin/env bash - set -euo pipefail - - SRC="${wallpaperSrc}" - DST="${wallpaperDst}" - - mkdir -p "$SRC" "$DST" - - ######################################## - # 2-way sync (additive, newer wins) - ######################################## - - # SRC -> DST - rsync -au "$SRC/" "$DST/" - - # DST -> SRC - rsync -au "$DST/" "$SRC/" - - ######################################## - # Initialize swww (safe if already running) - ######################################## - if ! pgrep -x swww-daemon >/dev/null; then - swww init - sleep 1 - fi - - ######################################## - # Get workspaces - ######################################## - WORKSPACES=$(hyprctl workspaces -j | jq -r '.[].id') - - ######################################## - # Function: set random wallpaper for workspace - ######################################## - set_wallpaper() { - local WS="$1" - - WALL=$(find "$DST" -type f | shuf -n 1) - - if [ -n "$WALL" ]; then - hyprctl dispatch workspace "$WS" - swww img "$WALL" --transition-type any - fi - } - - ######################################## - # If workspace passed → only update that - ######################################## - if [ "$#" -eq 1 ]; then - set_wallpaper "$1" - exit 0 - fi - - ######################################## - # Otherwise: update all workspaces - ######################################## - for WS in $WORKSPACES; do - set_wallpaper "$WS" - done - ''; + username = config.defaultUser or "henrov"; + homeDir = "/home/${username}"; + wallpaperDir = "${homeDir}/Wallpapers"; + scriptDest = "${homeDir}/Wallpapers/wallpaper-sync-and-set.sh"; in { - ################################# - # Packages - ################################# + ############################ + # Systemwide packages + ############################ environment.systemPackages = with pkgs; [ swww waypaper @@ -2430,48 +2377,38 @@ in rsync ]; - ################################# - # Service: main worker - ################################# + ############################ + # Install the script + ############################ + home.file."Wallpapers/wallpaper-sync-and-set.sh".source = ./assets/Wallpapers/wallpaper-sync-and-set.sh; + home.file."Wallpapers/wallpaper-sync-and-set.sh".executable = true; + + ############################ + # Systemd user service + timer + ############################ systemd.user.services.wallpaperSync = { description = "2-way sync wallpapers + set random per workspace"; - after = [ "graphical-session.target" ]; - - serviceConfig = { - Type = "oneshot"; - ExecStart = "${script}"; - }; - - wantedBy = [ "default.target" ]; # run at login + serviceConfig.Type = "oneshot"; + serviceConfig.ExecStart = "${scriptDest}"; + serviceConfig.Restart = "on-failure"; }; - ################################# - # Timer: every hour - ################################# - systemd.user.timers.wallpaperSync = { - description = "Run wallpaper sync hourly"; - + systemd.user.timers.wallpaperSyncTimer = { + description = "Run wallpaper sync every hour"; wantedBy = [ "timers.target" ]; - - timerConfig = { - OnBootSec = "2min"; - OnUnitActiveSec = "1h"; - Persistent = true; - }; + timerConfig.OnCalendar = "hourly"; + timerConfig.Persistent = true; }; - ################################# - # Hyprland integration (new workspace) - ################################# - # This assumes you manage Hyprland via Nix/Home Manager - ################################# - environment.etc."hypr/hyprland.conf".text = lib.mkAfter '' - # Run wallpaper script when workspace changes - bind = SUPER, Return, exec, ${script} - - # Hook: when workspace is created/switched - exec-once = hyprctl --batch "dispatch exec ${script}" - ''; + ############################ + # Run at login + ############################ + systemd.user.services.wallpaperSyncLogin = { + description = "Run wallpaper sync at login"; + serviceConfig.Type = "oneshot"; + serviceConfig.ExecStart = "${scriptDest}"; + install.WantedBy = [ "default.target" ]; + }; } #+END_SRC diff --git a/Droidnix/assets/traveldroid/Wallpapers/set-wallpapers-per-workspace.sh b/Droidnix/assets/traveldroid/Wallpapers/set-wallpapers-per-workspace.sh index 6b9aad131..893ab2eb6 100755 --- a/Droidnix/assets/traveldroid/Wallpapers/set-wallpapers-per-workspace.sh +++ b/Droidnix/assets/traveldroid/Wallpapers/set-wallpapers-per-workspace.sh @@ -1,11 +1,36 @@ #!/usr/bin/env bash -WALLS=("${HOME}/Wallpapers"/*) -NUM_WALLS=${#WALLS[@]} +set -euo pipefail -# Get workspace IDs -WS_IDS=($(hyprctl workspaces -j | jq -r '.[].id')) +# Determine repo root dynamically +repoRoot="$(dirname "$(readlink -f "$0")")/../.." +wallpaperSrc="$repoRoot/assets/Wallpapers" +wallpaperDst="$HOME/Wallpapers" -for i in "${!WS_IDS[@]}"; do - WALL="${WALLS[$((i % NUM_WALLS))]}" - swww img "$WALL" --workspace "${WS_IDS[$i]}" --transition-type fade slide blend zoom wipe cube fade-zoom slide-zoom -done +mkdir -p "$wallpaperDst" + +# 2-way sync (add only, overwrite if newer, never delete) +rsync -au --ignore-existing "$wallpaperSrc/" "$wallpaperDst/" +rsync -tu "$wallpaperDst/" "$wallpaperSrc/" + +# Gather wallpapers +mapfile -t wallpapers < <(find "$wallpaperDst" -type f) +numWallpapers=${#wallpapers[@]} + +if [[ $numWallpapers -eq 0 ]]; then + echo "No wallpapers found in $wallpaperDst" + exit 1 +fi + +# Check if a workspace ID is passed +if [[ $# -eq 1 ]]; then + ws="$1" + randomIndex=$(( RANDOM % numWallpapers )) + swww img "${wallpapers[$randomIndex]}" --transition-fade 1 --workspace "$ws" +else + # Full refresh for all workspaces + workspaces=$(hyprctl workspaces -j | jq -r '.[].id') + for ws in $workspaces; do + randomIndex=$(( RANDOM % numWallpapers )) + swww img "${wallpapers[$randomIndex]}" --transition-fade 1 --workspace "$ws" + done +fi diff --git a/Droidnix/generated/.config/hypr/hyprland.conf b/Droidnix/generated/.config/hypr/hyprland.conf index 54c872181..92701c151 100644 --- a/Droidnix/generated/.config/hypr/hyprland.conf +++ b/Droidnix/generated/.config/hypr/hyprland.conf @@ -7,7 +7,7 @@ source = ./layer-rules.conf source = ./layout.conf source = ./monitor-rules.conf # source = ./window-rules.conf -# source = ./workspace-rules.conf +source = ./workspace-rules.conf exec-once = /nix/store/c9cnbxhxbagj7gfpc1g5hl4x4f8dzayv-dbus-1.16.2/bin/dbus-update-activation-environment --systemd DISPLAY HYPRLAND_INSTANCE_SIGNATURE WAYLAND_DISPLAY XDG_CURRENT_DESKTOP XDG_SESSION_TYPE && systemctl --user stop hyprland-session.target && systemctl --user start hyprland-session.target diff --git a/Droidnix/generated/.config/hypr/workspace-rules.conf b/Droidnix/generated/.config/hypr/workspace-rules.conf index 53bd7ee63..94fa3ad62 100644 --- a/Droidnix/generated/.config/hypr/workspace-rules.conf +++ b/Droidnix/generated/.config/hypr/workspace-rules.conf @@ -1,3 +1,8 @@ +#Load random wallpaper +workspacecreated = exec $HOME/.local/bin/wallpaper-sync-and-set.sh $workspace + +/* + # Workspace definitions (modern syntax) workspace = 1 workspace = 2 @@ -5,6 +10,7 @@ workspace = 3 workspace = 4 workspace = 5 +/* # Auto-launch apps on specific workspaces (use `exec` with `workspace` rule) exec-once = kitty, workspace 1 exec-once = flatpak run app.betterbird.zen, workspace 2 @@ -28,3 +34,5 @@ windowrule = move workspace 3, ^(libreoffice)$ workspace { cycle_move_empty = no } + +*/ diff --git a/Droidnix/generated/modules/traveldroid/desktop/wallpaper.nix b/Droidnix/generated/modules/traveldroid/desktop/wallpaper.nix index bc03b2ade..75a69ad14 100644 --- a/Droidnix/generated/modules/traveldroid/desktop/wallpaper.nix +++ b/Droidnix/generated/modules/traveldroid/desktop/wallpaper.nix @@ -1,77 +1,15 @@ -{ config, pkgs, lib, flakeRoot, ... }: +{ config, pkgs, lib, ... }: let - username = config.defaultUser or "henrov"; - homeDir = "/home/${username}"; - wallpaperSrc = "${flakeRoot}/assets/Wallpapers"; - wallpaperDst = "${homeDir}/Wallpapers"; - - script = pkgs.writeShellScript "wallpaper-sync-and-set.sh" '' - #!/usr/bin/env bash - set -euo pipefail - - SRC="${wallpaperSrc}" - DST="${wallpaperDst}" - - mkdir -p "$SRC" "$DST" - - ######################################## - # 2-way sync (additive, newer wins) - ######################################## - - # SRC -> DST - rsync -au "$SRC/" "$DST/" - - # DST -> SRC - rsync -au "$DST/" "$SRC/" - - ######################################## - # Initialize swww (safe if already running) - ######################################## - if ! pgrep -x swww-daemon >/dev/null; then - swww init - sleep 1 - fi - - ######################################## - # Get workspaces - ######################################## - WORKSPACES=$(hyprctl workspaces -j | jq -r '.[].id') - - ######################################## - # Function: set random wallpaper for workspace - ######################################## - set_wallpaper() { - local WS="$1" - - WALL=$(find "$DST" -type f | shuf -n 1) - - if [ -n "$WALL" ]; then - hyprctl dispatch workspace "$WS" - swww img "$WALL" --transition-type any - fi - } - - ######################################## - # If workspace passed → only update that - ######################################## - if [ "$#" -eq 1 ]; then - set_wallpaper "$1" - exit 0 - fi - - ######################################## - # Otherwise: update all workspaces - ######################################## - for WS in $WORKSPACES; do - set_wallpaper "$WS" - done - ''; + username = config.defaultUser or "henrov"; + homeDir = "/home/${username}"; + wallpaperDir = "${homeDir}/Wallpapers"; + scriptDest = "${homeDir}/Wallpapers/wallpaper-sync-and-set.sh"; in { - ################################# - # Packages - ################################# + ############################ + # Systemwide packages + ############################ environment.systemPackages = with pkgs; [ swww waypaper @@ -79,46 +17,36 @@ in rsync ]; - ################################# - # Service: main worker - ################################# + ############################ + # Install the script + ############################ + home.file."Wallpapers/wallpaper-sync-and-set.sh".source = ./assets/Wallpapers/wallpaper-sync-and-set.sh; + home.file."Wallpapers/wallpaper-sync-and-set.sh".executable = true; + + ############################ + # Systemd user service + timer + ############################ systemd.user.services.wallpaperSync = { description = "2-way sync wallpapers + set random per workspace"; - after = [ "graphical-session.target" ]; - - serviceConfig = { - Type = "oneshot"; - ExecStart = "${script}"; - }; - - wantedBy = [ "default.target" ]; # run at login + serviceConfig.Type = "oneshot"; + serviceConfig.ExecStart = "${scriptDest}"; + serviceConfig.Restart = "on-failure"; }; - ################################# - # Timer: every hour - ################################# - systemd.user.timers.wallpaperSync = { - description = "Run wallpaper sync hourly"; - + systemd.user.timers.wallpaperSyncTimer = { + description = "Run wallpaper sync every hour"; wantedBy = [ "timers.target" ]; - - timerConfig = { - OnBootSec = "2min"; - OnUnitActiveSec = "1h"; - Persistent = true; - }; + timerConfig.OnCalendar = "hourly"; + timerConfig.Persistent = true; }; - ################################# - # Hyprland integration (new workspace) - ################################# - # This assumes you manage Hyprland via Nix/Home Manager - ################################# - environment.etc."hypr/hyprland.conf".text = lib.mkAfter '' - # Run wallpaper script when workspace changes - bind = SUPER, Return, exec, ${script} - - # Hook: when workspace is created/switched - exec-once = hyprctl --batch "dispatch exec ${script}" - ''; + ############################ + # Run at login + ############################ + systemd.user.services.wallpaperSyncLogin = { + description = "Run wallpaper sync at login"; + serviceConfig.Type = "oneshot"; + serviceConfig.ExecStart = "${scriptDest}"; + install.WantedBy = [ "default.target" ]; + }; }