use dwl-session in dwl script and add swayidle and waylock

This commit is contained in:
2026-07-28 18:00:35 +02:00
parent e314dc626c
commit 387de1f3cd
8 changed files with 184 additions and 8 deletions
+10 -1
View File
@@ -48,6 +48,7 @@
xdg = {
enable = true;
autostart.enable = true;
mime.enable = true;
mimeApps.enable = true;
mimeApps.defaultApplications = {
@@ -67,6 +68,7 @@
};
home.pointerCursor = {
enable = true;
name = "Adwaita";
package = pkgs.adwaita-icon-theme;
size = 24;
@@ -76,7 +78,14 @@
services.ssh-agent.enable = true;
services.gnome-keyring.enable = true;
# programs.keepassxc = {
# autostart = true;
# enable = true;
# settings = {
# # For available settings, see https://github.com/keepassxreboot/keepassxc/blob/develop/src/core/Config.cpp
# FdoSecrets.Enabled = true; # Enable Secret Service Integration
# };
# };
services.mako = {
enable = true;
+1 -1
View File
@@ -83,8 +83,8 @@
tree
dust
eza
wl-clipboard
keepassxc
wl-clipboard
btop
cargo
rustc
+8
View File
@@ -26,6 +26,12 @@ static char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
/* logging */
static int log_level = WLR_ERROR;
/* Autostart */
static const char *const autostart[] = {
"wbg", "/home/vbm/Pictures/Wallpapers/d3.png", NULL,
NULL /* terminate */
};
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
@@ -125,6 +131,7 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
/* commands */
static const char *termcmd[] = { "foot", NULL };
static const char *lockcmd[] = { "waylock", "-init-color", "0x444444", "-input-color", "0x005577", "-input-alt-color", "0x005577", "-fail-color", "0x770000", NULL };
static const char *menucmd[] = { "wmenu-drun", "-i", "-f", "Hack 9", NULL };
static const char *loudcmd[] = { "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "1%+", NULL };
static const char *quietcmd[] = { "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "1%-", NULL };
@@ -149,6 +156,7 @@ static const Key keys[] = {
{ 0, XKB_KEY_XF86MonBrightnessUp, spawn, {.v = brightcmd} },
{ 0, XKB_KEY_XF86MonBrightnessDown, spawn, {.v = dimcmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Delete, spawn, {.v = shutdowncmd} },
{ MODKEY, XKB_KEY_o, spawn, {.v = lockcmd} },
/* custom */
{ MODKEY, XKB_KEY_b, togglebar, {0} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
+8 -2
View File
@@ -148,12 +148,11 @@
packages = with pkgs; [
(import ../../scripts/dwls.nix { inherit pkgs lib; })
wmenu
dwl
tree
dust
eza
wl-clipboard
keepassxc
wl-clipboard
btop
fluffychat
cargo
@@ -179,10 +178,17 @@
gamescope
gamemode
mangohud
waylock
];
};
programs.dwl = {
enable = true;
package = pkgs.dwl;
};
security.rtkit.enable = true;
security.pam.services.waylock.enable = true;
hardware.acpilight.enable = true;
+12 -3
View File
@@ -1,6 +1,4 @@
{
...
}:
{ lib, pkgs, ... }:
{
imports = [
@@ -32,4 +30,15 @@
"65"
];
};
services.swayidle = {
enable = true;
timeouts = [
{
command = "${lib.getExe pkgs.waylock} -init-color 0x444444 -input-color 0x005577 -input-alt-color 0x005577 -fail-color 0x770000";
timeout = 300;
}
];
};
}
+1
View File
@@ -16,6 +16,7 @@
patches = oldAttrs.patches or [ ] ++ [
./patches/dwl/bar.patch
./patches/dwl/xwayland-handle-minimize.patch
./patches/dwl/autostart.patch
];
});
})
+141
View File
@@ -0,0 +1,141 @@
From d2e2e61aeb25ad71c2c559994968ba64e0974503 Mon Sep 17 00:00:00 2001
From: A Frederick Christensen <dwl@ivories.org>
Date: Fri, 27 Feb 2026 12:23:04 -0600
Subject: [PATCH] Applied autostart patch
---
config.def.h | 6 ++++++
dwl.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 61 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index 8a6eda0..6eb0db4 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,6 +20,12 @@ static const float fullscreen_bg[] = {0.0f, 0.0f, 0.0f, 1.0f}; /* You ca
/* logging */
static int log_level = WLR_ERROR;
+/* Autostart */
+static const char *const autostart[] = {
+ "wbg", "/path/to/your/image", NULL,
+ NULL /* terminate */
+};
+
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
diff --git a/dwl.c b/dwl.c
index 44f3ad9..e7b6199 100644
--- a/dwl.c
+++ b/dwl.c
@@ -246,6 +246,7 @@ static void arrange(Monitor *m);
static void arrangelayer(Monitor *m, struct wl_list *list,
struct wlr_box *usable_area, int exclusive);
static void arrangelayers(Monitor *m);
+static void autostartexec(void);
static void axisnotify(struct wl_listener *listener, void *data);
static void buttonpress(struct wl_listener *listener, void *data);
static void chvt(const Arg *arg);
@@ -449,6 +450,9 @@ static struct wl_listener xwayland_ready = {.notify = xwaylandready};
static struct wlr_xwayland *xwayland;
#endif
+static pid_t *autostart_pids;
+static size_t autostart_len;
+
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -603,6 +607,27 @@ arrangelayers(Monitor *m)
}
}
+void
+autostartexec(void) {
+ const char *const *p;
+ size_t i = 0;
+
+ /* count entries */
+ for (p = autostart; *p; autostart_len++, p++)
+ while (*++p);
+
+ autostart_pids = calloc(autostart_len, sizeof(pid_t));
+ for (p = autostart; *p; i++, p++) {
+ if ((autostart_pids[i] = fork()) == 0) {
+ setsid();
+ execvp(*p, (char *const *)p);
+ die("dwl: execvp %s:", *p);
+ }
+ /* skip arguments */
+ while (*++p);
+ }
+}
+
void
axisnotify(struct wl_listener *listener, void *data)
{
@@ -699,12 +724,23 @@ checkidleinhibitor(struct wlr_surface *exclude)
void
cleanup(void)
{
+ size_t i;
+
cleanuplisteners();
#ifdef XWAYLAND
wlr_xwayland_destroy(xwayland);
xwayland = NULL;
#endif
wl_display_destroy_clients(dpy);
+
+ /* kill child processes */
+ for (i = 0; i < autostart_len; i++) {
+ if (0 < autostart_pids[i]) {
+ kill(autostart_pids[i], SIGTERM);
+ waitpid(autostart_pids[i], NULL, 0);
+ }
+ }
+
if (child_pid > 0) {
kill(-child_pid, SIGTERM);
waitpid(child_pid, NULL, 0);
@@ -1560,10 +1596,25 @@ gpureset(struct wl_listener *listener, void *data)
void
handlesig(int signo)
{
- if (signo == SIGCHLD)
- while (waitpid(-1, NULL, WNOHANG) > 0);
- else if (signo == SIGINT || signo == SIGTERM)
+ if (signo == SIGCHLD) {
+ pid_t pid, *p, *lim;
+ while ((pid = waitpid(-1, NULL, WNOHANG)) > 0) {
+ if (pid == child_pid)
+ child_pid = -1;
+ if (!(p = autostart_pids))
+ continue;
+ lim = &p[autostart_len];
+
+ for (; p < lim; p++) {
+ if (*p == pid) {
+ *p = -1;
+ break;
+ }
+ }
+ }
+ } else if (signo == SIGINT || signo == SIGTERM) {
quit(NULL);
+ }
}
void
@@ -2250,6 +2301,7 @@ run(char *startup_cmd)
die("startup: backend_start");
/* Now that the socket exists and the backend is started, run the startup command */
+ autostartexec();
if (startup_cmd) {
int piperw[2];
if (pipe(piperw) < 0)
--
2.52.0
+3 -1
View File
@@ -1,4 +1,6 @@
{ pkgs, lib }:
pkgs.writeShellScriptBin "dwls" ''
${lib.getExe pkgs.slstatus} -s | ${lib.getExe pkgs.dwl} -s "${lib.getExe pkgs.wbg} ~/Pictures/Wallpapers/d3.png"
export PATH=$PATH:${pkgs.wbg}/bin
${lib.getExe pkgs.slstatus} -s | /etc/xdg/dwl-session
''