Compare commits

..

1 Commits

Author SHA1 Message Date
Sravan Balaji
3298080ded Add setupenv patch 2024-09-22 21:05:58 -04:00
33 changed files with 165 additions and 3065 deletions

5
.envrc
View File

@@ -1,5 +0,0 @@
export DIRENV_WARN_TIMEOUT=20s
eval "$(devenv direnvrc)"
use devenv

10
.gitignore vendored
View File

@@ -4,13 +4,3 @@ dwl
*-protocol.h
.ccls-cache
patches.h
# Devenv
.devenv*
devenv.local.nix
# direnv
.direnv
# pre-commit
.pre-commit-config.yaml

View File

@@ -76,7 +76,6 @@ dist: clean
install: dwl
mkdir -p $(DESTDIR)$(PREFIX)/bin
rm -f $(DESTDIR)$(PREFIX)/bin/dwl
cp -f dwl $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/dwl
mkdir -p $(DESTDIR)$(MANDIR)/man1

1085
README.org

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +1,22 @@
/* Taken from https://github.com/djpohly/dwl/issues/466 */
#define COLOR(hex) { ((hex >> 24) & 0xFF) / 255.0f, \
((hex >> 16) & 0xFF) / 255.0f, \
((hex >> 8) & 0xFF) / 255.0f, \
(hex & 0xFF) / 255.0f }
((hex >> 16) & 0xFF) / 255.0f, \
((hex >> 8) & 0xFF) / 255.0f, \
(hex & 0xFF) / 255.0f }
/* appearance */
static const int sloppyfocus = 1; /* focus follows mouse */
static const int bypass_surface_visibility = 0; /* 1 means idle inhibitors will disable idle tracking even if it's surface isn't visible */
#if VANITYGAPS_PATCH
static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static const int monoclegaps = 0; /* 1 means outer gaps in monocle layout */
#endif // VANITYGAPS_PATCH
static const unsigned int borderpx = 1; /* border pixel of windows */
#if VANITYGAPS_PATCH
static const unsigned int gappih = 10; /* horiz inner gap between windows */
static const unsigned int gappiv = 10; /* vert inner gap between windows */
static const unsigned int gappoh = 10; /* horiz outer gap between windows and screen edge */
static const unsigned int gappov = 10; /* vert outer gap between windows and screen edge */
#endif // VANITYGAPS_PATCH
static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
#if FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
static const float floatcolor[] = COLOR(0xff0000ff);
#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
@@ -33,28 +26,17 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* logging */
static int log_level = WLR_ERROR;
#if MENU_PATCH
static const Menu menus[] = {
/* command feed function action function */
{ "rofi -dmenu -i", menuwinfeed, menuwinaction },
{ "rofi -dmenu -i", menulayoutfeed, menulayoutaction },
};
#endif // MENU_PATCH
#if SETUPENV_PATCH
static const Env envs[] = {
/* variable value */
{ "XDG_CURRENT_DESKTOP", "wlroots" },
};
#endif // SETUPENV_PATCH
/* Autostart */
#if AUTOSTART_PATCH
static const char *const autostart[] = {
"wbg", "/path/to/your/image", NULL,
NULL /* terminate */
"wbg", "/path/to/your/image", NULL,
NULL /* terminate */
};
#endif // AUTOSTART_PATCH
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
@@ -70,9 +52,6 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
#if GAPLESSGRID_PATCH
{ "###", gaplessgrid },
#endif // GAPLESSGRID_PATCH
};
/* monitors */
@@ -116,9 +95,6 @@ static const int natural_scrolling = 0;
static const int disable_while_typing = 1;
static const int left_handed = 0;
static const int middle_button_emulation = 0;
#if UNCLUTTER_PATCH
static const int cursor_timeout = 5;
#endif // UNCLUTTER_PATCH
/* You can choose between:
LIBINPUT_CONFIG_SCROLL_NO_SCROLL
LIBINPUT_CONFIG_SCROLL_2FG
@@ -180,15 +156,10 @@ static const Key keys[] = {
#endif // IPC_PATCH
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
#if MOVESTACK_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_J, movestack, {.i = +1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, movestack, {.i = -1} },
#endif // MOVESTACK_PATCH
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
{ MODKEY, XKB_KEY_l, setmfact, {.f = +0.05f} },
#if VANITYGAPS_PATCH
{ MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_h, incgaps, {.i = +1 } },
{ MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_l, incgaps, {.i = -1 } },
{ MODKEY|WLR_MODIFIER_LOGO|WLR_MODIFIER_SHIFT, XKB_KEY_H, incogaps, {.i = +1 } },
@@ -205,26 +176,15 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_LOGO, XKB_KEY_o, incohgaps, {.i = -1 } },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Y, incovgaps, {.i = +1 } },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O, incovgaps, {.i = -1 } },
#endif // VANITYGAPS_PATCH
{ MODKEY, XKB_KEY_Return, zoom, {0} },
{ MODKEY, XKB_KEY_Tab, view, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_C, killclient, {0} },
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
#if GAPLESSGRID_PATCH
{ MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
#endif // GAPLESSGRID_PATCH
{ MODKEY, XKB_KEY_space, setlayout, {0} },
#if MENU_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT|WLR_MODIFIER_CTRL, XKB_KEY_p, menu, {.v = &menus[0]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_P, menu, {.v = &menus[1]} },
#endif // MENU_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
#if FAKE_FULLSCREEN_CLIENT_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_E, togglefakefullscreen, {0} },
#endif // FAKE_FULLSCREEN_CLIENT_PATCH
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },

View File

@@ -20,9 +20,6 @@ static const float rootcolor[] = COLOR(0x282a36ff);
static const float bordercolor[] = COLOR(0x4d4d4dff);
static const float focuscolor[] = COLOR(0xbd93f9ff);
static const float urgentcolor[] = COLOR(0xff5555ff);
#if FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
static const float floatcolor[] = COLOR(0xff79c6ff);
#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
@@ -31,47 +28,53 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
static int log_level = WLR_ERROR;
#if MENU_PATCH
static const Menu menus[] = {
/* command feed function action function */
{ "rofi -dmenu -i", menuwinfeed, menuwinaction },
{ "rofi -dmenu -i", menulayoutfeed, menulayoutaction },
};
#endif // MENU_PATCH
#if SETUPENV_PATCH
static const Env envs[] = {
/* variable value */
{ "XDG_CURRENT_DESKTOP", "wlroots" },
/* variable value */
{ "TERM", "xterm-256color" },
{ "SHELL", "/bin/fish" },
{ "EDITOR", "emacs" },
{ "GIT_EDITOR", "emacs" },
{ "BROWSER", "vivaldi-stable" },
{ "QT_QPA_PLATFORMTHEME", "qt6ct" },
{ "_JAVA_AWT_WM_NONREPARENTING", "1" },
{ "XDG_CURRENT_DESKTOP", "wlroots" },
};
#endif // SETUPENV_PATCH
#if AUTOSTART_PATCH
static const char *const autostart[] = {
"wbg", "/path/to/your/image", NULL,
NULL /* terminate */
/* Display / Compositor Setup */
"/usr/bin/shikane", NULL,
"/usr/bin/bash", "/home/sravan/.azotebg", NULL,
"/usr/bin/gammastep", "-x", NULL,
/* Background Processes */
"/usr/libexec/polkit-gnome-authentication-agent-1", NULL,
"/usr/bin/kdeconnectd", "--replace", NULL,
"/usr/bin/bash", "/home/sravan/.scripts/dunst.sh", "--on", NULL,
"/usr/bin/wl-paste", "--type", "text", "--watch", "cliphist", "store", NULL,
"/usr/bin/wl-paste", "--type", "image", "--watch", "cliphist", "store", NULL,
/* Tray Applications */
"/usr/bin/gammastep-indicator", NULL,
"/usr/bin/blueman-applet", NULL,
"/usr/bin/nm-applet", NULL,
"/usr/bin/kdeconnect-indicator", NULL,
"/usr/bin/flameshot", NULL,
"/usr/bin/udiskie", "-a", "-n", "-s", NULL,
/* GUI Applications */
"/usr/bin/nextcloud", NULL,
"/usr/bin/syncthing-gtk", NULL,
"/usr/bin/openrgb", NULL,
NULL /* terminate */
};
#endif // AUTOSTART_PATCH
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
{ "thunderbird-esr", NULL, 1 << 0, 0, -1 }, /* Start on ONLY tag "1" */
{ "Beeper", NULL, 1 << 1, 0, -1 }, /* Start on ONLY tag "2" */
{ "zoom", NULL, 1 << 1, 0, -1 }, /* Start on ONLY tag "2" */
{ "Signal", NULL, 1 << 1, 0, -1 }, /* Start on ONLY tag "2" */
{ "discord", NULL, 1 << 1, 0, -1 }, /* Start on ONLY tag "2" */
{ "obsidian", NULL, 1 << 2, 0, -1 }, /* Start on ONLY tag "3" */
{ "pocket-casts-linux", NULL, 1 << 3, 0, -1 }, /* Start on ONLY tag "4" */
{ "Spotify", NULL, 1 << 3, 0, -1 }, /* Start on ONLY tag "4" */
{ "Vivaldi-stable", NULL, 1 << 4, 0, -1 }, /* Start on ONLY tag "5" */
{ "foot", NULL, 1 << 5, 0, -1 }, /* Start on ONLY tag "6" */
{ "Emacs", NULL, 1 << 6, 0, -1 }, /* Start on ONLY tag "7" */
{ "steam", NULL, 1 << 7, 0, -1 }, /* Start on ONLY tag "8" */
{ "lutris", NULL, 1 << 7, 0, -1 }, /* Start on ONLY tag "8" */
{ "net.davidotek.pupgui2", NULL, 1 << 7, 0, -1 }, /* Start on ONLY tag "8" */
{ "gamescope", NULL, 1 << 7, 0, -1 }, /* Start on ONLY tag "8" */
{ "syncthing-gtk", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
{ "openrgb", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
/* app_id title tags mask isfloating monitor */
/* examples: */
{ "Gimp_EXAMPLE", NULL, 0, 1, -1 }, /* Start on currently visible tags floating, not tiled */
{ "firefox_EXAMPLE", NULL, 1 << 8, 0, -1 }, /* Start on ONLY tag "9" */
};
static const Layout layouts[] = {
@@ -79,9 +82,6 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
#if GAPLESSGRID_PATCH
{ "###", gaplessgrid },
#endif // GAPLESSGRID_PATCH
};
/* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator
@@ -122,9 +122,6 @@ static const int natural_scrolling = 1;
static const int disable_while_typing = 1;
static const int left_handed = 0;
static const int middle_button_emulation = 0;
#if UNCLUTTER_PATCH
static const int cursor_timeout = 5;
#endif // UNCLUTTER_PATCH
/* You can choose between:
LIBINPUT_CONFIG_SCROLL_NO_SCROLL
@@ -173,7 +170,7 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
static const char *termcmd[] = { "foot", NULL };
static const char *termcmd[] = { "kitty", NULL };
static const char *menucmd[] = { "rofi", "-show", "combi", NULL };
static const Key keys[] = {
@@ -186,10 +183,6 @@ static const Key keys[] = {
#endif // IPC_PATCH
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
#if MOVESTACK_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_J, movestack, {.i = +1} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, movestack, {.i = -1} },
#endif // MOVESTACK_PATCH
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05f} },
@@ -218,19 +211,9 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
#if GAPLESSGRID_PATCH
{ MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
#endif // GAPLESSGRID_PATCH
{ MODKEY, XKB_KEY_space, setlayout, {0} },
#if MENU_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT|WLR_MODIFIER_CTRL, XKB_KEY_p, menu, {.v = &menus[0]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_P, menu, {.v = &menus[1]} },
#endif // MENU_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
#if FAKE_FULLSCREEN_CLIENT_PATCH
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_E, togglefakefullscreen, {0} },
#endif // FAKE_FULLSCREEN_CLIENT_PATCH
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },

View File

@@ -1,103 +0,0 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1745604263,
"owner": "cachix",
"repo": "devenv",
"rev": "36807c727e743e7a00999922e7f737a0cc4e05ac",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1733328505,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1742649964,
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1733477122,
"owner": "cachix",
"repo": "devenv-nixpkgs",
"rev": "7bd9e84d0452f6d2e63b6e6da29fe73fac951857",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "rolling",
"repo": "devenv-nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"git-hooks": "git-hooks",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": [
"git-hooks"
]
}
}
},
"root": "root",
"version": 7
}

View File

@@ -1,19 +0,0 @@
{ pkgs, lib, config, inputs, ... }:
{
# https://devenv.sh/packages/
packages = [
pkgs.git
pkgs.yaml-language-server
pkgs.gdb
];
# https://devenv.sh/languages/
languages.c = {
enable = true;
debugger = pkgs.gdb;
};
languages.cplusplus = {
enable = true;
};
}

View File

@@ -1,15 +0,0 @@
# yaml-language-server: $schema=https://devenv.sh/devenv.schema.json
inputs:
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
# If you're using non-OSS software, you can set allowUnfree to true.
# allowUnfree: true
# If you're willing to use a package that's vulnerable
# permittedInsecurePackages:
# - "openssl-1.1.1w"
# If you have more than one devenv you can merge them
#imports:
# - ./backend

453
dwl.c
View File

@@ -162,11 +162,7 @@ typedef struct {
#endif // XWAYLAND
unsigned int bw;
uint32_t tags;
#if !FAKE_FULLSCREEN_CLIENT_PATCH
int isfloating, isurgent, isfullscreen;
#else // FAKE_FULLSCREEN_CLIENT_PATCH
int isfloating, isurgent, isfullscreen, isfakefullscreen;
#endif // FAKE_FULLSCREEN_CLIENT_PATCH
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -296,14 +292,6 @@ typedef struct {
struct wl_listener destroy;
} SessionLock;
#if MENU_PATCH
typedef struct {
const char *cmd; /* command to run a menu */
void (*feed)(FILE *f); /* feed input to menu */
void (*action)(char *line); /* do action based on menu output */
} Menu;
#endif // MENU_PATCH
/* function declarations */
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
@@ -372,13 +360,6 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
#if GAPLESSGRID_PATCH
static void gaplessgrid(Monitor *m);
#endif // GAPLESSGRID_PATCH
#if UNCLUTTER_PATCH
static void handlecursoractivity(void);
static int hidecursor(void *data);
#endif // UNCLUTTER_PATCH
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
#if VANITYGAPS_PATCH
@@ -399,18 +380,7 @@ static void killclient(const Arg *arg);
static void locksession(struct wl_listener *listener, void *data);
static void mapnotify(struct wl_listener *listener, void *data);
static void maximizenotify(struct wl_listener *listener, void *data);
#if MENU_PATCH
static void menu(const Arg *arg);
static int menuloop(void *data);
static void menuwinfeed(FILE *f);
static void menuwinaction(char *line);
static void menulayoutfeed(FILE *f);
static void menulayoutaction(char *line);
#endif // MENU_PATCH
static void monocle(Monitor *m);
#if MOVESTACK_PATCH
static void movestack(const Arg *arg);
#endif // MOVESTACK_PATCH
static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(uint32_t time, struct wlr_input_device *device, double sx,
double sy, double sx_unaccel, double sy_unaccel);
@@ -434,9 +404,6 @@ static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
static void setfullscreen(Client *c, int fullscreen);
#if FAKE_FULLSCREEN_CLIENT_PATCH
static void setfakefullscreen(Client *c, int fullscreen);
#endif // FAKE_FULLSCREEN_CLIENT_PATCH
static void setgamma(struct wl_listener *listener, void *data);
#if VANITYGAPS_PATCH
static void setgaps(int oh, int ov, int ih, int iv);
@@ -457,9 +424,6 @@ static void togglebar(const Arg *arg);
#endif // IPC_PATCH
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
#if FAKE_FULLSCREEN_CLIENT_PATCH
static void togglefakefullscreen(const Arg *arg);
#endif // FAKE_FULLSCREEN_CLIENT_PATCH
#if VANITYGAPS_PATCH
static void togglegaps(const Arg *arg);
#endif // VANITYGAPS_PATCH
@@ -531,16 +495,6 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
static struct wlr_cursor *cursor;
static struct wlr_xcursor_manager *cursor_mgr;
#if UNCLUTTER_PATCH
static struct wl_event_source *hide_source;
static bool cursor_hidden = false;
static struct {
enum wp_cursor_shape_device_v1_shape shape;
struct wlr_surface *surface;
int hotspot_x;
int hotspot_y;
} last_cursor;
#endif // UNCLUTTER_PATCH
static struct wlr_scene_rect *root_bg;
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
@@ -563,13 +517,6 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
#if MENU_PATCH
static struct wl_event_source *menu_source;
static pid_t menu_pid;
static int menu_fd;
static const Menu *menu_current;
#endif // MENU_PATCH
#if IPC_PATCH
static struct zdwl_ipc_manager_v2_interface dwl_manager_implementation = {.release = dwl_ipc_manager_release, .get_output = dwl_ipc_manager_get_output};
static struct zdwl_ipc_output_v2_interface dwl_output_implementation = {.release = dwl_ipc_output_release, .set_tags = dwl_ipc_output_set_tags, .set_layout = dwl_ipc_output_set_layout, .set_client_tags = dwl_ipc_output_set_client_tags};
@@ -666,14 +613,6 @@ applyrules(Client *c)
}
}
}
#if ALWAYSCENTER_PATCH
if (mon) {
c->geom.x = (mon->w.width - c->geom.width) / 2 + mon->m.x;
c->geom.y = (mon->w.height - c->geom.height) / 2 + mon->m.y;
}
#endif // ALWAYSCENTER_PATCH
setmon(c, mon, newtags);
}
@@ -809,9 +748,6 @@ axisnotify(struct wl_listener *listener, void *data)
* for example when you move the scroll wheel. */
struct wlr_pointer_axis_event *event = data;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
#if UNCLUTTER_PATCH
handlecursoractivity();
#endif // UNCLUTTER_PATCH
/* TODO: allow usage of scroll whell for mousebindings, it can be implemented
* checking the event's orientation and the delta of the event */
/* Notify the client with pointer focus of the axis event. */
@@ -830,9 +766,6 @@ buttonpress(struct wl_listener *listener, void *data)
const Button *b;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
#if UNCLUTTER_PATCH
handlecursoractivity();
#endif // UNCLUTTER_PATCH
switch (event->state) {
case WL_POINTER_BUTTON_STATE_PRESSED:
@@ -865,9 +798,6 @@ buttonpress(struct wl_listener *listener, void *data)
/* Drop the window off on its new monitor */
selmon = xytomon(cursor->x, cursor->y);
setmon(grabc, selmon, 0);
#if FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
grabc = NULL;
#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
return;
} else {
cursor_mode = CurNormal;
@@ -914,9 +844,6 @@ cleanup(void)
wlr_xwayland_destroy(xwayland);
xwayland = NULL;
#endif // XWAYLAND
#if MENU_PATCH
wl_event_source_remove(menu_source);
#endif // MENU_PATCH
wl_display_destroy_clients(dpy);
#if AUTOSTART_PATCH
@@ -975,7 +902,7 @@ cleanupmon(struct wl_listener *listener, void *data)
wlr_scene_output_destroy(m->scene_output);
#if PERTAG_PATCH
free(m->pertag);
free(m->pertag);
#endif // PERTAG_PATCH
closemon(m);
wlr_scene_node_destroy(&m->fullscreen_bg->node);
@@ -1506,6 +1433,7 @@ void
destroydecoration(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, destroy_decoration);
c->decoration = NULL;
wl_list_remove(&c->destroy_decoration.link);
wl_list_remove(&c->set_decoration_mode.link);
@@ -1971,13 +1899,9 @@ focusclient(Client *c, int lift)
/* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg
* and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
#if !FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
client_set_border_color(old_c, bordercolor);
client_activate_surface(old, 0);
#else // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
client_set_border_color(old_c, old_c->isfloating ? floatcolor : bordercolor);
client_activate_surface(old, 0);
#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
#if FOREIGN_TOPLEVEL_MANAGEMENT_PATCH
if (old_c->foreign_toplevel)
wlr_foreign_toplevel_handle_v1_set_activated(old_c->foreign_toplevel, 0);
@@ -2089,58 +2013,6 @@ gpureset(struct wl_listener *listener, void *data)
wlr_renderer_destroy(old_drw);
}
#if GAPLESSGRID_PATCH
void
gaplessgrid(Monitor *m)
{
unsigned int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
Client *c;
wl_list_for_each(c, &clients, link)
if (VISIBLEON(c, m) && !c->isfloating)
n++;
if (n == 0)
return;
/* grid dimensions */
for (cols = 0; cols <= (n / 2); cols++)
if ((cols * cols) >= n)
break;
if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
cols = 2;
/* widescreen is better if 3 columns */
if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
cols = 3;
rows = n / cols;
/* window geometries */
cw = cols ? m->w.width / cols : m->w.width;
cn = 0; /* current column number */
rn = 0; /* current row number */
wl_list_for_each(c, &clients, link) {
unsigned int cx, cy;
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue;
if ((i / rows + 1) > (cols - n % cols))
rows = n / cols + 1;
ch = rows ? m->w.height / rows : m->w.height;
cx = m->w.x + cn * cw;
cy = m->w.y + rn * ch;
resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0);
rn++;
if (rn >= rows) {
rn = 0;
cn++;
}
i++;
}
}
#endif // GAPLESSGRID_PATCH
void
handlesig(int signo)
{
@@ -2180,9 +2052,9 @@ handlesig(int signo)
*/
while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid
&& (!xwayland || in.si_pid != xwayland->server->pid))
waitpid(in.si_pid, NULL, 0);
waitpid(in.si_pid, NULL, 0);
#else // XWAYLAND
while (waitpid(-1, NULL, WNOHANG) > 0);
while (waitpid(-1, NULL, WNOHANG) > 0);
#endif // XWAYLAND
#endif // AUTOSTART_PATCH
} else if (signo == SIGINT || signo == SIGTERM) {
@@ -2190,34 +2062,6 @@ handlesig(int signo)
}
}
#if UNCLUTTER_PATCH
void
handlecursoractivity(void)
{
wl_event_source_timer_update(hide_source, cursor_timeout * 1000);
if (!cursor_hidden)
return;
cursor_hidden = false;
if (last_cursor.shape)
wlr_cursor_set_xcursor(cursor, cursor_mgr,
wlr_cursor_shape_v1_name(last_cursor.shape));
else
wlr_cursor_set_surface(cursor, last_cursor.surface,
last_cursor.hotspot_x, last_cursor.hotspot_y);
}
int
hidecursor(void *data)
{
wlr_cursor_unset_image(cursor);
cursor_hidden = true;
return 1;
}
#endif // UNCLUTTER_PATCH
void
incnmaster(const Arg *arg)
{
@@ -2529,7 +2373,7 @@ mapnotify(struct wl_listener *listener, void *data)
else
wl_list_insert(&clients, &c->link);
#else // ATTACHTOP_PATCH
wl_list_insert(&clients, &c->link);
wl_list_insert(&clients, &c->link);
#endif // ATTACHTOP_PATCH
wl_list_insert(&fstack, &c->flink);
@@ -2539,12 +2383,6 @@ mapnotify(struct wl_listener *listener, void *data)
* try to apply rules for them */
if ((p = client_get_parent(c))) {
c->isfloating = 1;
#if ALWAYSCENTER_PATCH
if (p->mon) {
c->geom.x = (p->mon->w.width - c->geom.width) / 2 + p->mon->m.x;
c->geom.y = (p->mon->w.height - c->geom.height) / 2 + p->mon->m.y;
}
#endif // ALWAYSCENTER_PATCH
setmon(c, p->mon, p->tags);
} else {
applyrules(c);
@@ -2583,138 +2421,6 @@ maximizenotify(struct wl_listener *listener, void *data)
wlr_xdg_surface_schedule_configure(c->surface.xdg);
}
#if MENU_PATCH
void
menu(const Arg *arg)
{
FILE *f;
pid_t pid;
int fd_right[2], fd_left[2];
if (!selmon || menu_pid != 0)
return;
menu_current = arg->v;
if (pipe(fd_right) == -1 || pipe(fd_left) == -1)
return;
if ((pid = fork()) == -1)
return;
if (pid == 0) {
close(fd_right[1]);
close(fd_left[0]);
dup2(fd_right[0], STDIN_FILENO);
close(fd_right[0]);
dup2(fd_left[1], STDOUT_FILENO);
close(fd_left[1]);
execl("/bin/sh", "/bin/sh", "-c", menu_current->cmd, NULL);
die("dwl: execl %s failed:", "/bin/sh");
}
close(fd_right[0]);
close(fd_left[1]);
if (!(f = fdopen(fd_right[1], "w")))
return;
menu_current->feed(f);
fclose(f);
menu_pid = pid;
menu_fd = fd_left[0];
wl_event_source_timer_update(menu_source, 10);
}
int
menuloop(void *data)
{
FILE *f;
pid_t pid;
char line[256], *s;
/* If process is still running, wait for another 50 ms */
if ((pid = waitpid(menu_pid, NULL, WNOHANG)) == 0) {
wl_event_source_timer_update(menu_source, 10);
return 0;
}
menu_pid = 0;
if (!(f = fdopen(menu_fd, "r")))
return 0;
if (fgets(line, sizeof(line), f)) {
if ((s = strchr(line, '\n')))
*s = '\0';
menu_current->action(line);
}
fclose(f);
return 0;
}
void
menuwinfeed(FILE *f)
{
Client *c;
const char *title;
wl_list_for_each(c, &fstack, flink) {
if (!(title = client_get_title(c)))
continue;
fprintf(f, "%s\n", title);
}
}
void
menuwinaction(char *line)
{
Client *c;
Monitor *prevm = selmon;
const char *title;
if (!selmon)
return;
wl_list_for_each(c, &fstack, flink) {
if (!(title = client_get_title(c)))
continue;
if (strcmp(line, title) == 0)
goto found;
}
return;
found:
focusclient(c, 1);
wlr_cursor_move(cursor, NULL, selmon->m.x - prevm->m.x , 0);
selmon->seltags ^= 1; /* toggle sel tagset */
selmon->tagset[selmon->seltags] = c->tags;
arrange(selmon);
printstatus();
}
void
menulayoutfeed(FILE *f)
{
unsigned int i;
for (i = 0; i < LENGTH(layouts); i++)
fprintf(f, "%s\n", layouts[i].symbol);
}
void
menulayoutaction(char *line)
{
unsigned int i;
Arg a;
for (i = 0; i < LENGTH(layouts); i++)
if (strcmp(line, layouts[i].symbol) == 0)
goto found;
return;
found:
a.v = &layouts[i];
setlayout(&a);
}
#endif // MENU_PATCH
void
monocle(Monitor *m)
{
@@ -2732,8 +2438,8 @@ monocle(Monitor *m)
resize(c, (struct wlr_box){.x = m->w.x + gappoh, .y = m->w.y + gappov,
.width = m->w.width - 2 * gappoh, .height = m->w.height - 2 * gappov}, 0);
#else // VANITYGAPS_PATCH
resize(c, m->w, 0);
n++;
resize(c, m->w, 0);
n++;
#endif // VANITYGAPS_PATCH
}
if (n)
@@ -2742,42 +2448,6 @@ monocle(Monitor *m)
wlr_scene_node_raise_to_top(&c->scene->node);
}
#if MOVESTACK_PATCH
void
movestack(const Arg *arg)
{
Client *c, *sel = focustop(selmon);
if (!sel) {
return;
}
if (wl_list_length(&clients) <= 1) {
return;
}
if (arg->i > 0) {
wl_list_for_each(c, &sel->link, link) {
if (VISIBLEON(c, selmon) || &c->link == &clients) {
break; /* found it */
}
}
} else {
wl_list_for_each_reverse(c, &sel->link, link) {
if (VISIBLEON(c, selmon) || &c->link == &clients) {
break; /* found it */
}
}
/* backup one client */
c = wl_container_of(c->link.prev, c, link);
}
wl_list_remove(&sel->link);
wl_list_insert(&c->link, &sel->link);
arrange(selmon);
}
#endif // MOVESTACK_PATCH
void
motionabsolute(struct wl_listener *listener, void *data)
{
@@ -2848,9 +2518,6 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
wlr_cursor_move(cursor, device, dx, dy);
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
#if UNCLUTTER_PATCH
handlecursoractivity();
#endif // UNCLUTTER_PATCH
/* Update selmon (even while dragging a window) */
if (sloppyfocus)
@@ -2875,11 +2542,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
#if !UNCLUTTER_PATCH
if (!surface && !seat->drag)
#else // UNCLUTTER_PATCH
if (!surface && !seat->drag && !cursor_hidden)
#endif // UNCLUTTER_PATCH
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
pointerfocus(c, surface, sx, sy, time);
@@ -3274,9 +2937,6 @@ run(char *startup_cmd)
* monitor when displayed here */
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
#if UNCLUTTER_PATCH
handlecursoractivity();
#endif // UNCLUTTER_PATCH
/* Run the Wayland event loop. This does not return until you exit the
* compositor. Starting the backend rigged up all of the necessary event
@@ -3300,22 +2960,9 @@ setcursor(struct wl_listener *listener, void *data)
* use the provided surface as the cursor image. It will set the
* hardware cursor on the output that it's currently on and continue to
* do so as the cursor moves between outputs. */
#if !UNCLUTTER_PATCH
if (event->seat_client == seat->pointer_state.focused_client)
wlr_cursor_set_surface(cursor, event->surface,
event->hotspot_x, event->hotspot_y);
#else // UNCLUTTER_PATCH
if (event->seat_client == seat->pointer_state.focused_client) {
last_cursor.shape = 0;
last_cursor.surface = event->surface;
last_cursor.hotspot_x = event->hotspot_x;
last_cursor.hotspot_y = event->hotspot_y;
if (!cursor_hidden)
wlr_cursor_set_surface(cursor, event->surface,
event->hotspot_x, event->hotspot_y);
}
#endif // UNCLUTTER_PATCH
}
void
@@ -3327,20 +2974,9 @@ setcursorshape(struct wl_listener *listener, void *data)
/* This can be sent by any client, so we check to make sure this one is
* actually has pointer focus first. If so, we can tell the cursor to
* use the provided cursor shape. */
#if !UNCLUTTER_PATCH
if (event->seat_client == seat->pointer_state.focused_client)
wlr_cursor_set_xcursor(cursor, cursor_mgr,
wlr_cursor_shape_v1_name(event->shape));
#else // UNCLUTTER_PATCH
if (event->seat_client == seat->pointer_state.focused_client) {
last_cursor.shape = event->shape;
last_cursor.surface = NULL;
if (!cursor_hidden)
wlr_cursor_set_xcursor(cursor, cursor_mgr,
wlr_cursor_shape_v1_name(event->shape));
}
#endif // UNCLUTTER_PATCH
}
void
@@ -3354,13 +2990,6 @@ setfloating(Client *c, int floating)
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
(p && p->isfullscreen) ? LyrFS
: c->isfloating ? LyrFloat : LyrTile]);
#if FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
if (!grabc && floating)
for (int i = 0; i < 4; i++) {
wlr_scene_rect_set_color(c->border[i], floatcolor);
wlr_scene_node_lower_to_bottom(&c->border[i]->node);
}
#endif // FLOAT_UNFOCUSED_BORDER_COLOR_PATCH
arrange(c->mon);
printstatus();
}
@@ -3388,19 +3017,6 @@ setfullscreen(Client *c, int fullscreen)
printstatus();
}
#if FAKE_FULLSCREEN_CLIENT_PATCH
void
setfakefullscreen(Client *c, int fullscreen)
{
c->isfakefullscreen = fullscreen;
if (!c->mon)
return;
if (c->isfullscreen)
setfullscreen(c, 0);
client_set_fullscreen(c, fullscreen);
}
#endif // FAKE_FULLSCREEN_CLIENT_PATCH
void
setgamma(struct wl_listener *listener, void *data)
{
@@ -3484,15 +3100,15 @@ setmon(Client *c, Monitor *m, uint32_t newtags)
if (c->foreign_toplevel)
wlr_foreign_toplevel_handle_v1_output_leave(c->foreign_toplevel, oldmon->wlr_output);
arrange(oldmon);
}
}
#endif // FOREIGN_TOPLEVEL_MANAGEMENT_PATCH
if (m) {
/* Make sure window actually overlaps with the monitor */
resize(c, c->geom, 0);
c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */
#if FOREIGN_TOPLEVEL_MANAGEMENT_PATCH
if (c->foreign_toplevel)
wlr_foreign_toplevel_handle_v1_output_enter(c->foreign_toplevel, m->wlr_output);
if (c->foreign_toplevel)
wlr_foreign_toplevel_handle_v1_output_enter(c->foreign_toplevel, m->wlr_output);
#endif // FOREIGN_TOPLEVEL_MANAGEMENT_PATCH
setfullscreen(c, c->isfullscreen); /* This will call arrange(c->mon) */
setfloating(c, c->isfloating);
@@ -3700,11 +3316,6 @@ setup(void)
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
LISTEN_STATIC(&cursor_shape_mgr->events.request_set_shape, setcursorshape);
#if UNCLUTTER_PATCH
hide_source = wl_event_loop_add_timer(wl_display_get_event_loop(dpy),
hidecursor, cursor);
#endif // UNCLUTTER_PATCH
/*
* Configures a seat, which is a single "seat" at which a user sits and
* operates the computer. This conceptually includes up to one keyboard,
@@ -3739,12 +3350,6 @@ setup(void)
* e.g when running in the x11 backend or the wayland backend and the
* compositor has Xwayland support */
unsetenv("DISPLAY");
#if MENU_PATCH
menu_source = wl_event_loop_add_timer(
wl_display_get_event_loop(dpy), menuloop, NULL);
#endif // MENU_PATCH
#ifdef XWAYLAND
/*
* Initialise the XWayland X server.
@@ -3810,8 +3415,8 @@ tagmon(const Arg *arg)
die("oom");
}
#else // RESTORE_MONITOR_PATCH
if (sel)
setmon(sel, dirtomon(arg->i), 0);
if (sel)
setmon(sel, dirtomon(arg->i), 0);
#endif // RESTORE_MONITOR_PATCH
}
@@ -3850,8 +3455,8 @@ tile(Monitor *m)
i = 0;
my = ty = m->gappoh*oe;
#else // VANITYGAPS_PATCH
mw = m->w.width;
i = my = ty = 0;
mw = m->w.width;
i = my = ty = 0;
#endif // VANITYGAPS_PATCH
wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
@@ -3864,9 +3469,9 @@ tile(Monitor *m)
.width = mw - m->gappiv*ie, .height = h}, 0);
my += c->geom.height + m->gappih*ie;
#else // VANITYGAPS_PATCH
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
my += c->geom.height;
resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
.height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
my += c->geom.height;
#endif // VANITYGAPS_PATCH
} else {
#if VANITYGAPS_PATCH
@@ -3876,9 +3481,9 @@ tile(Monitor *m)
.width = m->w.width - mw - 2*m->gappov*oe, .height = h}, 0);
ty += c->geom.height + m->gappih*ie;
#else // VANITYGAPS_PATCH
resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
.width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
ty += c->geom.height;
resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
.width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
ty += c->geom.height;
#endif // VANITYGAPS_PATCH
}
i++;
@@ -3911,16 +3516,6 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen);
}
#if FAKE_FULLSCREEN_CLIENT_PATCH
void
togglefakefullscreen(const Arg *arg)
{
Client *sel = focustop(selmon);
if (sel)
setfakefullscreen(sel, !sel->isfakefullscreen);
}
#endif // FAKE_FULLSCREEN_CLIENT_PATCH
#if VANITYGAPS_PATCH
void
togglegaps(const Arg *arg)
@@ -4181,6 +3776,7 @@ view(const Arg *arg)
#if PERTAG_PATCH
size_t i, tmptag;
#endif // PERTAG_PATCH
//
if (!selmon || (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
return;
selmon->seltags ^= 1; /* toggle sel tagset */
@@ -4239,9 +3835,6 @@ virtualpointer(struct wl_listener *listener, void *data)
wlr_cursor_attach_input_device(cursor, device);
if (event->suggested_output)
wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
#if UNCLUTTER_PATCH
handlecursoractivity();
#endif // UNCLUTTER_PATCH
}
#if WARPCURSOR_PATCH
@@ -4475,7 +4068,7 @@ sethints(struct wl_listener *listener, void *data)
{
Client *c = wl_container_of(listener, c, set_hints);
struct wlr_surface *surface = client_surface(c);
if (c == focustop(selmon) || !c->surface.xwayland->hints)
if (c == focustop(selmon))
return;
c->isurgent = xcb_icccm_wm_hints_get_urgency(c->surface.xwayland->hints);

View File

@@ -7,7 +7,3 @@ default:
# Rebuild project
dwl-rebuild:
sudo make clean all
# Run waybar with dwl configuration
dwl-launch-waybar:
./waybar/launch.sh

View File

@@ -1,23 +1,11 @@
#define ALWAYSCENTER_PATCH 1
#define ATTACHTOP_PATCH 1
#define AUTOSTART_PATCH 0
#define FAKE_FULLSCREEN_CLIENT_PATCH 1
#define FLOAT_UNFOCUSED_BORDER_COLOR_PATCH 1
#define AUTOSTART_PATCH 1
#define FOREIGN_TOPLEVEL_MANAGEMENT_PATCH 1
#define GAPLESSGRID_PATCH 1
#define IPC_PATCH 1
#define MENU_PATCH 1
#define MOVESTACK_PATCH 1
#define NATURALSCROLLTRACKPAD_PATCH 1
#define NUMLOCK_CAPSLOCK_PATCH 1
@@ -26,9 +14,7 @@
#define RESTORE_MONITOR_PATCH 1
#define SETUPENV_PATCH 0
#define UNCLUTTER_PATCH 1
#define SETUPENV_PATCH 1
#define VANITYGAPS_PATCH 1

View File

@@ -1,38 +0,0 @@
From 6616470ef135019ef4c767003a66df76df45f53e Mon Sep 17 00:00:00 2001
From: Guido Cella <guido@guidocella.xyz>
Date: Wed, 5 Jun 2024 12:05:16 +0200
Subject: [PATCH] center floating windows
---
dwl.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/dwl.c b/dwl.c
index 6f041a0..79ace52 100644
--- a/dwl.c
+++ b/dwl.c
@@ -472,6 +472,10 @@ applyrules(Client *c)
}
}
}
+ if (mon) {
+ c->geom.x = (mon->w.width - c->geom.width) / 2 + mon->m.x;
+ c->geom.y = (mon->w.height - c->geom.height) / 2 + mon->m.y;
+ }
setmon(c, mon, newtags);
}
@@ -1677,6 +1681,10 @@ mapnotify(struct wl_listener *listener, void *data)
* try to apply rules for them */
if ((p = client_get_parent(c))) {
c->isfloating = 1;
+ if (p->mon) {
+ c->geom.x = (p->mon->w.width - c->geom.width) / 2 + p->mon->m.x;
+ c->geom.y = (p->mon->w.height - c->geom.height) / 2 + p->mon->m.y;
+ }
setmon(c, p->mon, p->tags);
} else {
applyrules(c);
--
2.45.1

View File

@@ -1,87 +0,0 @@
From 2ec6d0c668b4daee601337f8da45ccfa3a7d5fc6 Mon Sep 17 00:00:00 2001
From: choc <notchoc@proton.me>
Date: Fri, 29 Mar 2024 22:50:00 +0800
Subject: [PATCH] implement fakefullscreenclient
---
config.def.h | 1 +
dwl.c | 23 ++++++++++++++++++++++-
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/config.def.h b/config.def.h
index 9009517..8c220eb 100644
--- a/config.def.h
+++ b/config.def.h
@@ -137,6 +137,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_E, togglefakefullscreen, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_parenright, tag, {.ui = ~0} },
{ MODKEY, XKB_KEY_comma, focusmon, {.i = WLR_DIRECTION_LEFT} },
diff --git a/dwl.c b/dwl.c
index 5867b0c..1e78491 100644
--- a/dwl.c
+++ b/dwl.c
@@ -137,7 +137,7 @@ typedef struct {
#endif
unsigned int bw;
uint32_t tags;
- int isfloating, isurgent, isfullscreen;
+ int isfloating, isurgent, isfullscreen, isfakefullscreen;
uint32_t resize; /* configure serial of a pending resize */
} Client;
@@ -318,6 +318,7 @@ static void setcursor(struct wl_listener *listener, void *data);
static void setcursorshape(struct wl_listener *listener, void *data);
static void setfloating(Client *c, int floating);
static void setfullscreen(Client *c, int fullscreen);
+static void setfakefullscreen(Client *c, int fullscreen);
static void setgamma(struct wl_listener *listener, void *data);
static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg);
@@ -332,6 +333,7 @@ static void tagmon(const Arg *arg);
static void tile(Monitor *m);
static void togglefloating(const Arg *arg);
static void togglefullscreen(const Arg *arg);
+static void togglefakefullscreen(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unlocksession(struct wl_listener *listener, void *data);
@@ -2181,6 +2183,17 @@ setfullscreen(Client *c, int fullscreen)
printstatus();
}
+void
+setfakefullscreen(Client *c, int fullscreen)
+{
+ c->isfakefullscreen = fullscreen;
+ if (!c->mon)
+ return;
+ if (c->isfullscreen)
+ setfullscreen(c, 0);
+ client_set_fullscreen(c, fullscreen);
+}
+
void
setgamma(struct wl_listener *listener, void *data)
{
@@ -2620,6 +2633,14 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen);
}
+void
+togglefakefullscreen(const Arg *arg)
+{
+ Client *sel = focustop(selmon);
+ if (sel)
+ setfakefullscreen(sel, !sel->isfakefullscreen);
+}
+
void
toggletag(const Arg *arg)
{
--
2.44.0

View File

@@ -1,60 +0,0 @@
From 591c031a4d8e62acfef4ef41816c1fbbb8b1473a Mon Sep 17 00:00:00 2001
From: yuki <yukiat@proton.me>
Date: Fri, 7 Jun 2024 11:44:37 +0800
Subject: [PATCH] Added float-unfocused-border-color patch.
---
config.def.h | 1 +
dwl.c | 11 ++++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/config.def.h b/config.def.h
index a784eb4..8131af5 100644
--- a/config.def.h
+++ b/config.def.h
@@ -11,6 +11,7 @@ static const float rootcolor[] = COLOR(0x222222ff);
static const float bordercolor[] = COLOR(0x444444ff);
static const float focuscolor[] = COLOR(0x005577ff);
static const float urgentcolor[] = COLOR(0xff0000ff);
+static const float floatcolor[] = COLOR(0xff0000ff);
/* This conforms to the xdg-protocol. Set the alpha to zero to restore the old behavior */
static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You can also use glsl colors */
diff --git a/dwl.c b/dwl.c
index 6f041a0..777c0e1 100644
--- a/dwl.c
+++ b/dwl.c
@@ -632,6 +632,7 @@ buttonpress(struct wl_listener *listener, void *data)
/* Drop the window off on its new monitor */
selmon = xytomon(cursor->x, cursor->y);
setmon(grabc, selmon, 0);
+ grabc = NULL;
return;
} else {
cursor_mode = CurNormal;
@@ -1348,9 +1349,8 @@ focusclient(Client *c, int lift)
/* Don't deactivate old client if the new one wants focus, as this causes issues with winecfg
* and probably other clients */
} else if (old_c && !client_is_unmanaged(old_c) && (!c || !client_wants_focus(c))) {
- client_set_border_color(old_c, bordercolor);
-
- client_activate_surface(old, 0);
+ client_set_border_color(old_c, old_c->isfloating ? floatcolor : bordercolor);
+ client_activate_surface(old, 0);
}
}
printstatus();
@@ -2218,6 +2218,11 @@ setfloating(Client *c, int floating)
wlr_scene_node_reparent(&c->scene->node, layers[c->isfullscreen ||
(p && p->isfullscreen) ? LyrFS
: c->isfloating ? LyrFloat : LyrTile]);
+ if (!grabc && floating)
+ for (int i = 0; i < 4; i++) {
+ wlr_scene_rect_set_color(c->border[i], floatcolor);
+ wlr_scene_node_lower_to_bottom(&c->border[i]->node);
+ }
arrange(c->mon);
printstatus();
}
--
2.45.2

View File

@@ -1,89 +0,0 @@
diff --git a/config.def.h b/config.def.h
index 22d2171..014a909 100644
--- a/config.def.h
+++ b/config.def.h
@@ -34,6 +34,7 @@ static const Layout layouts[] = {
{ "[]=", tile },
{ "><>", NULL }, /* no layout function means floating behavior */
{ "[M]", monocle },
+ { "###", gaplessgrid },
};
/* monitors */
@@ -139,6 +140,7 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
+ { MODKEY, XKB_KEY_g, setlayout, {.v = &layouts[3]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
diff --git a/dwl.c b/dwl.c
index dc0c861..875d8cd 100644
--- a/dwl.c
+++ b/dwl.c
@@ -292,6 +292,7 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
+static void gaplessgrid(Monitor *m);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -1510,6 +1511,56 @@ handlesig(int signo)
}
}
+void
+gaplessgrid(Monitor *m)
+{
+ unsigned int n = 0, i = 0, ch, cw, cn, rn, rows, cols;
+ Client *c;
+
+ wl_list_for_each(c, &clients, link)
+ if (VISIBLEON(c, m) && !c->isfloating)
+ n++;
+ if (n == 0)
+ return;
+
+ /* grid dimensions */
+ for (cols = 0; cols <= (n / 2); cols++)
+ if ((cols * cols) >= n)
+ break;
+
+ if (n == 5) /* set layout against the general calculation: not 1:2:2, but 2:3 */
+ cols = 2;
+
+ /* widescreen is better if 3 columns */
+ if (n >= 3 && n <= 6 && (m->w.width / m->w.height) > 1)
+ cols = 3;
+
+ rows = n / cols;
+
+ /* window geometries */
+ cw = cols ? m->w.width / cols : m->w.width;
+ cn = 0; /* current column number */
+ rn = 0; /* current row number */
+ wl_list_for_each(c, &clients, link) {
+ unsigned int cx, cy;
+ if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
+ continue;
+
+ if ((i / rows + 1) > (cols - n % cols))
+ rows = n / cols + 1;
+ ch = rows ? m->w.height / rows : m->w.height;
+ cx = m->w.x + cn * cw;
+ cy = m->w.y + rn * ch;
+ resize(c, (struct wlr_box) { cx, cy, cw, ch}, 0);
+ rn++;
+ if (rn >= rows) {
+ rn = 0;
+ cn++;
+ }
+ i++;
+ }
+}
+
void
incnmaster(const Arg *arg)
{

View File

@@ -1,230 +0,0 @@
commit 2d7e19dc948aec61746fd858394a9c80d34a3216
Author: Nikita Ivanov <nikita.vyach.ivanov@gmail.com>
Date: Sat Jul 13 01:05:20 2024 +0200
Add menu command
diff --git a/config.def.h b/config.def.h
index 22d2171..ecd2c67 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,6 +20,12 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* logging */
static int log_level = WLR_ERROR;
+static const Menu menus[] = {
+ /* command feed function action function */
+ { "wmenu -i -l 5 -p Windows", menuwinfeed, menuwinaction },
+ { "wmenu -i -p Layouts", menulayoutfeed, menulayoutaction },
+};
+
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
@@ -140,6 +146,8 @@ static const Key keys[] = {
{ MODKEY, XKB_KEY_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XKB_KEY_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XKB_KEY_space, setlayout, {0} },
+ { MODKEY, XKB_KEY_o, menu, {.v = &menus[0]} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_O, menu, {.v = &menus[1]} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_space, togglefloating, {0} },
{ MODKEY, XKB_KEY_e, togglefullscreen, {0} },
{ MODKEY, XKB_KEY_0, view, {.ui = ~0} },
diff --git a/dwl.c b/dwl.c
index dc0437e..90bb09a 100644
--- a/dwl.c
+++ b/dwl.c
@@ -241,6 +241,12 @@ typedef struct {
struct wl_listener destroy;
} SessionLock;
+typedef struct {
+ const char *cmd; /* command to run a menu */
+ void (*feed)(FILE *f); /* feed input to menu */
+ void (*action)(char *line); /* do action based on menu output */
+} Menu;
+
/* function declarations */
static void applybounds(Client *c, struct wlr_box *bbox);
static void applyrules(Client *c);
@@ -298,6 +304,12 @@ static void killclient(const Arg *arg);
static void locksession(struct wl_listener *listener, void *data);
static void mapnotify(struct wl_listener *listener, void *data);
static void maximizenotify(struct wl_listener *listener, void *data);
+static void menu(const Arg *arg);
+static int menuloop(void *data);
+static void menuwinfeed(FILE *f);
+static void menuwinaction(char *line);
+static void menulayoutfeed(FILE *f);
+static void menulayoutaction(char *line);
static void monocle(Monitor *m);
static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(uint32_t time, struct wlr_input_device *device, double sx,
@@ -408,6 +420,11 @@ static struct wlr_box sgeom;
static struct wl_list mons;
static Monitor *selmon;
+static struct wl_event_source *menu_source;
+static pid_t menu_pid;
+static int menu_fd;
+static const Menu *menu_current;
+
#ifdef XWAYLAND
static void activatex11(struct wl_listener *listener, void *data);
static void associatex11(struct wl_listener *listener, void *data);
@@ -675,6 +692,7 @@ cleanup(void)
wlr_xwayland_destroy(xwayland);
xwayland = NULL;
#endif
+ wl_event_source_remove(menu_source);
wl_display_destroy_clients(dpy);
if (child_pid > 0) {
kill(-child_pid, SIGTERM);
@@ -1717,6 +1735,136 @@ maximizenotify(struct wl_listener *listener, void *data)
wlr_xdg_surface_schedule_configure(c->surface.xdg);
}
+void
+menu(const Arg *arg)
+{
+ FILE *f;
+ pid_t pid;
+ int fd_right[2], fd_left[2];
+
+ if (!selmon || menu_pid != 0)
+ return;
+
+ menu_current = arg->v;
+
+ if (pipe(fd_right) == -1 || pipe(fd_left) == -1)
+ return;
+ if ((pid = fork()) == -1)
+ return;
+ if (pid == 0) {
+ close(fd_right[1]);
+ close(fd_left[0]);
+ dup2(fd_right[0], STDIN_FILENO);
+ close(fd_right[0]);
+ dup2(fd_left[1], STDOUT_FILENO);
+ close(fd_left[1]);
+
+ execl("/bin/sh", "/bin/sh", "-c", menu_current->cmd, NULL);
+ die("dwl: execl %s failed:", "/bin/sh");
+ }
+
+ close(fd_right[0]);
+ close(fd_left[1]);
+
+ if (!(f = fdopen(fd_right[1], "w")))
+ return;
+ menu_current->feed(f);
+ fclose(f);
+
+ menu_pid = pid;
+ menu_fd = fd_left[0];
+ wl_event_source_timer_update(menu_source, 10);
+}
+
+int
+menuloop(void *data)
+{
+ FILE *f;
+ pid_t pid;
+ char line[256], *s;
+
+ /* If process is still running, wait for another 50 ms */
+ if ((pid = waitpid(menu_pid, NULL, WNOHANG)) == 0) {
+ wl_event_source_timer_update(menu_source, 10);
+ return 0;
+ }
+
+ menu_pid = 0;
+
+ if (!(f = fdopen(menu_fd, "r")))
+ return 0;
+ if (fgets(line, sizeof(line), f)) {
+ if ((s = strchr(line, '\n')))
+ *s = '\0';
+ menu_current->action(line);
+ }
+ fclose(f);
+ return 0;
+}
+
+void
+menuwinfeed(FILE *f)
+{
+ Client *c;
+ const char *title;
+
+ wl_list_for_each(c, &fstack, flink) {
+ if (!(title = client_get_title(c)))
+ continue;
+ fprintf(f, "%s\n", title);
+ }
+}
+
+void
+menuwinaction(char *line)
+{
+ Client *c;
+ Monitor *prevm = selmon;
+ const char *title;
+
+ if (!selmon)
+ return;
+
+ wl_list_for_each(c, &fstack, flink) {
+ if (!(title = client_get_title(c)))
+ continue;
+ if (strcmp(line, title) == 0)
+ goto found;
+ }
+ return;
+
+found:
+ focusclient(c, 1);
+ wlr_cursor_move(cursor, NULL, selmon->m.x - prevm->m.x , 0);
+ selmon->seltags ^= 1; /* toggle sel tagset */
+ selmon->tagset[selmon->seltags] = c->tags;
+ arrange(selmon);
+ printstatus();
+}
+
+void
+menulayoutfeed(FILE *f)
+{
+ unsigned int i;
+ for (i = 0; i < LENGTH(layouts); i++)
+ fprintf(f, "%s\n", layouts[i].symbol);
+}
+
+void
+menulayoutaction(char *line)
+{
+ unsigned int i;
+ Arg a;
+ for (i = 0; i < LENGTH(layouts); i++)
+ if (strcmp(line, layouts[i].symbol) == 0)
+ goto found;
+ return;
+
+found:
+ a.v = &layouts[i];
+ setlayout(&a);
+}
+
void
monocle(Monitor *m)
{
@@ -2576,6 +2724,10 @@ setup(void)
* e.g when running in the x11 backend or the wayland backend and the
* compositor has Xwayland support */
unsetenv("DISPLAY");
+
+ menu_source = wl_event_loop_add_timer(
+ wl_display_get_event_loop(dpy), menuloop, NULL);
+
#ifdef XWAYLAND
/*
* Initialise the XWayland X server.

View File

@@ -1,79 +0,0 @@
From b051f50233033b399db324b29ab24227257ac141 Mon Sep 17 00:00:00 2001
From: wochap <gean.marroquin@gmail.com>
Date: Tue, 5 Mar 2024 23:31:51 -0500
Subject: [PATCH] apply NikitaIvanovV movestack patch
source: https://github.com/djpohly/dwl/wiki/movestack
---
config.def.h | 2 ++
dwl.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/config.def.h b/config.def.h
index db0babc..778a0dc 100644
--- a/config.def.h
+++ b/config.def.h
@@ -122,6 +122,8 @@ static const Key keys[] = {
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
{ MODKEY, XKB_KEY_j, focusstack, {.i = +1} },
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_J, movestack, {.i = +1} },
+ { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_K, movestack, {.i = -1} },
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
{ MODKEY, XKB_KEY_d, incnmaster, {.i = -1} },
{ MODKEY, XKB_KEY_h, setmfact, {.f = -0.05} },
diff --git a/dwl.c b/dwl.c
index ef27a1d..69b9756 100644
--- a/dwl.c
+++ b/dwl.c
@@ -279,6 +279,7 @@ static void maplayersurfacenotify(struct wl_listener *listener, void *data);
static void mapnotify(struct wl_listener *listener, void *data);
static void maximizenotify(struct wl_listener *listener, void *data);
static void monocle(Monitor *m);
+static void movestack(const Arg *arg);
static void motionabsolute(struct wl_listener *listener, void *data);
static void motionnotify(uint32_t time);
static void motionrelative(struct wl_listener *listener, void *data);
@@ -1603,6 +1604,40 @@ monocle(Monitor *m)
wlr_scene_node_raise_to_top(&c->scene->node);
}
+void
+movestack(const Arg *arg)
+{
+ Client *c, *sel = focustop(selmon);
+
+ if (!sel) {
+ return;
+ }
+
+ if (wl_list_length(&clients) <= 1) {
+ return;
+ }
+
+ if (arg->i > 0) {
+ wl_list_for_each(c, &sel->link, link) {
+ if (VISIBLEON(c, selmon) || &c->link == &clients) {
+ break; /* found it */
+ }
+ }
+ } else {
+ wl_list_for_each_reverse(c, &sel->link, link) {
+ if (VISIBLEON(c, selmon) || &c->link == &clients) {
+ break; /* found it */
+ }
+ }
+ /* backup one client */
+ c = wl_container_of(c->link.prev, c, link);
+ }
+
+ wl_list_remove(&sel->link);
+ wl_list_insert(&c->link, &sel->link);
+ arrange(selmon);
+}
+
void
motionabsolute(struct wl_listener *listener, void *data)
{
--
2.42.0

View File

@@ -1,188 +0,0 @@
From 52d5a05a6b4ca9555c072e103c2db454d2b35021 Mon Sep 17 00:00:00 2001
From: Guido Cella <guido@guidocella.xyz>
Date: Thu, 25 Jul 2024 17:59:05 +0200
Subject: [PATCH] =?UTF-8?q?hide=20the=20mouse=20cursor=20if=20it=20isn?=
=?UTF-8?q?=E2=80=99t=20being=20used?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
config.def.h | 2 ++
dwl.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++------
2 files changed, 65 insertions(+), 7 deletions(-)
diff --git a/config.def.h b/config.def.h
index 22d2171..790c73d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -106,6 +106,8 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
*/
static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
+static const int cursor_timeout = 5;
+
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
#define MODKEY WLR_MODIFIER_ALT
diff --git a/dwl.c b/dwl.c
index 72892d9..4090d73 100644
--- a/dwl.c
+++ b/dwl.c
@@ -292,6 +292,8 @@ static void focusstack(const Arg *arg);
static Client *focustop(Monitor *m);
static void fullscreennotify(struct wl_listener *listener, void *data);
static void gpureset(struct wl_listener *listener, void *data);
+static void handlecursoractivity(void);
+static int hidecursor(void *data);
static void handlesig(int signo);
static void incnmaster(const Arg *arg);
static void inputdevice(struct wl_listener *listener, void *data);
@@ -396,6 +398,14 @@ static struct wlr_pointer_constraint_v1 *active_constraint;
static struct wlr_cursor *cursor;
static struct wlr_xcursor_manager *cursor_mgr;
+static struct wl_event_source *hide_source;
+static bool cursor_hidden = false;
+static struct {
+ enum wp_cursor_shape_device_v1_shape shape;
+ struct wlr_surface *surface;
+ int hotspot_x;
+ int hotspot_y;
+} last_cursor;
static struct wlr_scene_rect *root_bg;
static struct wlr_session_lock_manager_v1 *session_lock_mgr;
@@ -588,6 +598,7 @@ axisnotify(struct wl_listener *listener, void *data)
* for example when you move the scroll wheel. */
struct wlr_pointer_axis_event *event = data;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ handlecursoractivity();
/* TODO: allow usage of scroll whell for mousebindings, it can be implemented
* checking the event's orientation and the delta of the event */
/* Notify the client with pointer focus of the axis event. */
@@ -606,6 +617,7 @@ buttonpress(struct wl_listener *listener, void *data)
const Button *b;
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ handlecursoractivity();
switch (event->state) {
case WL_POINTER_BUTTON_STATE_PRESSED:
@@ -1517,6 +1529,32 @@ handlesig(int signo)
}
}
+void
+handlecursoractivity(void)
+{
+ wl_event_source_timer_update(hide_source, cursor_timeout * 1000);
+
+ if (!cursor_hidden)
+ return;
+
+ cursor_hidden = false;
+
+ if (last_cursor.shape)
+ wlr_cursor_set_xcursor(cursor, cursor_mgr,
+ wlr_cursor_shape_v1_name(last_cursor.shape));
+ else
+ wlr_cursor_set_surface(cursor, last_cursor.surface,
+ last_cursor.hotspot_x, last_cursor.hotspot_y);
+}
+
+int
+hidecursor(void *data)
+{
+ wlr_cursor_unset_image(cursor);
+ cursor_hidden = true;
+ return 1;
+}
+
void
incnmaster(const Arg *arg)
{
@@ -1856,6 +1894,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
wlr_cursor_move(cursor, device, dx, dy);
wlr_idle_notifier_v1_notify_activity(idle_notifier, seat);
+ handlecursoractivity();
/* Update selmon (even while dragging a window) */
if (sloppyfocus)
@@ -1880,7 +1919,7 @@ motionnotify(uint32_t time, struct wlr_input_device *device, double dx, double d
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */
- if (!surface && !seat->drag)
+ if (!surface && !seat->drag && !cursor_hidden)
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
pointerfocus(c, surface, sx, sy, time);
@@ -2263,6 +2302,7 @@ run(char *startup_cmd)
* monitor when displayed here */
wlr_cursor_warp_closest(cursor, NULL, cursor->x, cursor->y);
wlr_cursor_set_xcursor(cursor, cursor_mgr, "default");
+ handlecursoractivity();
/* Run the Wayland event loop. This does not return until you exit the
* compositor. Starting the backend rigged up all of the necessary event
@@ -2286,9 +2326,16 @@ setcursor(struct wl_listener *listener, void *data)
* use the provided surface as the cursor image. It will set the
* hardware cursor on the output that it's currently on and continue to
* do so as the cursor moves between outputs. */
- if (event->seat_client == seat->pointer_state.focused_client)
- wlr_cursor_set_surface(cursor, event->surface,
- event->hotspot_x, event->hotspot_y);
+ if (event->seat_client == seat->pointer_state.focused_client) {
+ last_cursor.shape = 0;
+ last_cursor.surface = event->surface;
+ last_cursor.hotspot_x = event->hotspot_x;
+ last_cursor.hotspot_y = event->hotspot_y;
+
+ if (!cursor_hidden)
+ wlr_cursor_set_surface(cursor, event->surface,
+ event->hotspot_x, event->hotspot_y);
+ }
}
void
@@ -2300,9 +2347,14 @@ setcursorshape(struct wl_listener *listener, void *data)
/* This can be sent by any client, so we check to make sure this one is
* actually has pointer focus first. If so, we can tell the cursor to
* use the provided cursor shape. */
- if (event->seat_client == seat->pointer_state.focused_client)
- wlr_cursor_set_xcursor(cursor, cursor_mgr,
- wlr_cursor_shape_v1_name(event->shape));
+ if (event->seat_client == seat->pointer_state.focused_client) {
+ last_cursor.shape = event->shape;
+ last_cursor.surface = NULL;
+
+ if (!cursor_hidden)
+ wlr_cursor_set_xcursor(cursor, cursor_mgr,
+ wlr_cursor_shape_v1_name(event->shape));
+ }
}
void
@@ -2604,6 +2656,9 @@ setup(void)
cursor_shape_mgr = wlr_cursor_shape_manager_v1_create(dpy, 1);
LISTEN_STATIC(&cursor_shape_mgr->events.request_set_shape, setcursorshape);
+ hide_source = wl_event_loop_add_timer(wl_display_get_event_loop(dpy),
+ hidecursor, cursor);
+
/*
* Configures a seat, which is a single "seat" at which a user sits and
* operates the computer. This conceptually includes up to one keyboard,
@@ -2986,6 +3041,7 @@ virtualpointer(struct wl_listener *listener, void *data)
wlr_cursor_attach_input_device(cursor, device);
if (event->suggested_output)
wlr_cursor_map_input_to_output(cursor, device, event->suggested_output);
+ handlecursoractivity();
}
Monitor *
--
2.45.2

10
util.c
View File

@@ -38,14 +38,14 @@ ecalloc(size_t nmemb, size_t size)
int
fd_set_nonblock(int fd) {
int flags = fcntl(fd, F_GETFL);
if (flags < 0) {
if (flags < 0) {
perror("fcntl(F_GETFL):");
return -1;
}
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
return -1;
}
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
perror("fcntl(F_SETFL):");
return -1;
}
}
return 0;
}

View File

@@ -1,290 +0,0 @@
// -*- mode: jsonc -*-
{
"layer": "top", // Waybar at top layer
// "output": "",
"position": "top", // Waybar position (top|bottom|left|right)
// "height": 25, // Waybar height (to be removed for auto height)
// "width": 1280, // Waybar width
"spacing": 4, // Gaps between modules (4px)
"mode": "dock",
"start_hidden": false,
"fixed-center": true,
"reload_style_on_change": true,
"modules-left": [
"group/power-menu",
"dwl/tags",
"dwl/window#title",
"dwl/window#layout",
],
"modules-center": [
"tray",
],
"modules-right": [
"group/media-playing",
"pulseaudio",
"idle_inhibitor",
"custom/system76-power",
"cpu",
"memory",
"disk",
"battery",
"clock",
"group/dunst",
],
"group/power-menu": {
"orientation": "inherit",
"modules": [
"custom/power-menu-launcher",
"custom/power-menu-shutdown",
"custom/power-menu-reboot",
"custom/power-menu-sleep",
"custom/power-menu-lock",
"custom/power-menu-logout",
],
"drawer": {
"transition-duration": 500,
"transition-left-to-right": true,
"click-to-reveal": false,
},
},
"group/media-playing": {
"orientation": "inherit",
"modules": [
"custom/media-playing-source",
"custom/media-playing-prev",
"custom/media-playing-play-pause",
"custom/media-playing-next",
],
},
"group/dunst": {
"orientation": "inherit",
"modules": [
"custom/dunst-status",
"custom/dunst-history-view",
"custom/dunst-clear",
"custom/dunst-history-clear",
],
"drawer": {
"transition-duration": 500,
"transition-left-to-right": true,
"click-to-reveal": false,
},
},
"battery": {
"interval": 60,
"format": "{icon} {capacity}%",
"format-icons": ["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"],
"tooltip": true,
"tooltip-format": "󱧥\t{timeTo}\n󱐋\t{power} W\n󱠴\t{cycles}\n󱈏\t{health}%",
},
"cpu": {
"interval": 5,
"format": " {usage}%",
"tooltip": true,
"on-click-right": "foot btop",
},
"clock": {
"interval": 60,
"format": "󰥔 {:%I:%M %p}",
"tooltip": true,
"tooltip-format": "<tt><small>{calendar}</small></tt>",
"calendar": {
"mode" : "month",
"mode-mon-col" : 3,
"weeks-pos" : "left",
"on-scroll" : 1,
"format": {
"months": "<span color='#50fa7b'><b>{}</b></span>",
"days": "<span color='#f8f8f2'><b>{}</b></span>",
"weeks": "<span color='#8be9fd'><b>W{}</b></span>",
"weekdays": "<span color='#f1fa8c'><b>{}</b></span>",
"today": "<span color='#bd93f9'><b><u>{}</u></b></span>"
},
},
"actions": {
"on-click": "mode",
"on-click-right": "shift_reset",
"on-scroll-up": "shift_up",
"on-scroll-down": "shift_down",
},
},
"custom/dunst-status": {
"exec": "~/.config/dwl/waybar/scripts/dunst.sh",
"restart-interval": 1,
"on-click": "~/.scripts/dunst.sh --dnd",
"on-click-right": "~/.scripts/dunst.sh --rofi",
"tooltip": true,
"tooltip-format": "Toggle Do Not Disturb",
},
"custom/dunst-clear": {
"format": "",
"on-click": "~/.scripts/dunst.sh --close-all",
"tooltip": true,
"tooltip-format": "Close Open Notifications",
},
"custom/dunst-history-view": {
"format": "󰋚",
"on-click": "~/.scripts/dunst.sh --history",
"tooltip": true,
"tooltip-format": "View Notification History",
},
"custom/dunst-history-clear": {
"format": "󰎟",
"on-click": "~/.scripts/dunst.sh --history-clear",
"tooltip": true,
"tooltip-format": "Clear Notification History",
},
"dwl/tags": {
"num-tags": 9,
"tag-labels": [ "󰻧 ₁", "󰍩 ₂", "󰠮 ₃", " ₄", "󰖟 ₅", " ₆", "󰊢 ₇", "󰊖 ₈", " ₉" ],
"disable-click": false
},
"dwl/window#title": {
"format": "{title}",
"all-outputs": false,
"icon": true,
"icon-size": 21,
"tooltip": true,
"max-length": 30,
},
"dwl/window#layout": {
"format": "{layout}",
"tooltip": false,
"all-outputs": false,
"icon": false,
},
"disk": {
"interval": 60,
"format": "󰋊 {percentage_used}%",
"tooltip": true,
"tooltip-format": "Used: {used} ({percentage_used}%)\nFree: {free} ({percentage_free}%)\nTotal: {total}",
"on-click-right": "qdirstat",
},
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "󱄄 on",
"deactivated": "󰶐 off",
},
"tooltip": true,
"tooltip-format-activated": "Idle Inhibitor: {status}",
"tooltip-format-deactivated": "Idle Inhibitor: {status}",
"start-activated": true,
},
"memory": {
"interval": 5,
"format": " {percentage}%",
"tooltip": true,
"tooltip-format": "RAM:\n\tUsed: {used} GiB ({percentage}%)\n\tFree: {avail} GiB\n\tTotal: {total} GiB\nSwap:\n\tUsed: {swapUsed} GiB ({swapPercentage}%)\n\tFree: {swapAvail} GiB\n\tTotal: {swapTotal} GiB",
"on-click-right": "foot btop",
},
"custom/media-playing-source": {
"exec": "~/.config/dwl/waybar/scripts/get-media-playing.sh",
"return-type": "json",
"restart-interval": 1,
"on-click": "~/.scripts/playerctl.sh --change",
"tooltip": true,
},
"custom/media-playing-prev": {
"format": "󰒮",
"on-click": "~/.scripts/playerctl.sh --prev",
"tooltip": false,
},
"custom/media-playing-play-pause": {
"exec": "~/.config/dwl/waybar/scripts/get-media-status-icon.sh",
"restart-interval": 1,
"on-click": "~/.scripts/playerctl.sh --play-pause",
"tooltip": false,
},
"custom/media-playing-next": {
"format": "󰒭",
"on-click": "~/.scripts/playerctl.sh --next",
"tooltip": false,
},
"custom/power-menu-launcher": {
"format": "",
"on-click": "rofi -show combi",
"on-click-right": "~/.scripts/control-center.sh --rofi",
"tooltip": true,
"tooltip-format": "Application Launcher",
},
"custom/power-menu-shutdown": {
"format": "",
"on-click": "~/.scripts/session.sh --shutdown",
"tooltip": true,
"tooltip-format": "Shutdown",
},
"custom/power-menu-reboot": {
"format": "",
"on-click": "~/.scripts/session.sh --reboot",
"tooltip": true,
"tooltip-format": "Reboot",
},
"custom/power-menu-sleep": {
"format": "⏾",
"on-click": "~/.scripts/session.sh --sleep",
"tooltip": true,
"tooltip-format": "Sleep",
},
"custom/power-menu-lock": {
"format": "",
"on-click": "~/.scripts/session.sh --lock",
"tooltip": true,
"tooltip-format": "Lock",
},
"custom/power-menu-logout": {
"format": "",
"on-click": "~/.scripts/session.sh --logout",
"tooltip": true,
"tooltip-format": "Logout",
},
"pulseaudio": {
"interval": 5,
"format": "{icon} {volume}%",
"format-bluetooth": "{icon} 󰂯 {volume}%",
"format-muted": "󰝟 muted",
"format-icons": {
"hdmi": "󰡁",
"headset": "󰋎",
"speaker": "󰓃",
"headphone": "󰋋",
"car": "",
"hifi": "󰤽",
"default": "",
},
"scroll-step": 5,
"on-click": "~/.scripts/pactl.sh --mute",
"on-click-right": "~/.scripts/pactl.sh --mixer",
"tooltip": true,
"tooltip-format": "{desc}",
"scroll-step": 0.25,
},
"custom/system76-power": {
"exec": "~/.config/dwl/waybar/scripts/system76-power.sh",
"return-type": "json",
"restart-interval": 60,
"on-click-right": "~/.scripts/cpu-gpu.sh --rofi",
"tooltip": true,
},
"tray": {
"icon-size": 21,
"show-passive-items": true,
"spacing": 4,
"reverse-direction": false,
},
}

View File

@@ -1,15 +0,0 @@
#!/usr/bin/env bash
killall waybar || true
until /usr/bin/waybar \
--config $HOME/.config/dwl/waybar/config.jsonc \
--style $HOME/.config/dwl/waybar/style.css;
do
if [ $? -ne 143 ]; then
echo "Dwl Waybar stopped with exit code $?. Respawning..." >&2;
sleep 1;
else
echo "Dwl Waybar manually killed with SIGTERM";
break;
fi
done

View File

@@ -1,9 +0,0 @@
#!/usr/bin/env bash
isPaused=$(dunstctl is-paused)
notificationCount=$(dunstctl count history)
if [[ "$isPaused" == "true" ]]; then
echo "󰂛 $notificationCount"
else
echo "󰂚 $notificationCount"
fi

View File

@@ -1,33 +0,0 @@
#!/usr/bin/env bash
mediaSourceIcon=$(`dirname $0`/get-media-source-icon.sh)
mediaStatus=$(playerctl --player=playerctld metadata 2>&1)
if [[ "$mediaStatus" == "No player could handle this command" ]]; then
artist="N/A"
title="N/A"
album="N/A"
status="N/A"
else
artist=$(playerctl --player=playerctld metadata --format '{{ xesam:artist }}')
title=$(playerctl --player=playerctld metadata --format '{{ xesam:title }}')
album=$(playerctl --player=playerctld metadata --format '{{ xesam:album }}')
status=$(playerctl --player=playerctld metadata --format '{{ status }}')
if [[ $artist == "" ]]; then
artist="N/A"
fi
if [[ $title == "" ]]; then
title="N/A"
fi
if [[ $album == "" ]]; then
album="N/A"
fi
if [[ $status == "" ]]; then
status="N/A"
fi
fi
echo '{"text":"'$mediaSourceIcon'","tooltip":"󰝚\t'${title//'"'/'\"'}'\r󰠃\t'${artist//'"'/'\"'}'\r󰀥\t'${album//'"'/'\"'}'\r󰐎\t'${status//'"'/'\"'}'"}'

View File

@@ -1,27 +0,0 @@
#!/usr/bin/env bash
mediaStatus=$(playerctl --player=playerctld metadata 2>&1)
if [[ "$mediaStatus" == "No player could handle this command" ]]; then
echo "󰡀"
else
trackid=$(playerctl --player=playerctld metadata --format '{{ mpris:trackid }}')
title=$(playerctl --player=playerctld metadata --format '{{ xesam:title }}')
if grep -q -i "netflix" <<< "$title"; then
echo "󰝆"
elif grep -q -i "hulu" <<< "$title"; then
echo "󰠩"
elif grep -q -i "prime video" <<< "$title"; then
echo ""
elif grep -q -i "youtube tv" <<< "$title"; then
echo "󰑈"
elif grep -q -i "chromium" <<< "$trackid"; then
echo ""
elif grep -q -i "vlc" <<< "$trackid"; then
echo "󰕼"
elif grep -q -i "spotify" <<< "$trackid"; then
echo ""
else
echo "󰡀"
fi
fi

View File

@@ -1,12 +0,0 @@
#!/usr/bin/env bash
mediaStatus=$(`dirname $0`/get-media-status.sh)
if [[ "$mediaStatus" == "N/A" ]]; then
echo "󰐎"
else
if [[ "$mediaStatus" == "Playing" ]]; then
echo "󰏤"
elif [[ "$mediaStatus" == "Paused" ]]; then
echo "󰐊"
fi
fi

View File

@@ -1,10 +0,0 @@
#!/usr/bin/env bash
mediaStatus=$(playerctl --player=playerctld metadata 2>&1)
if [[ "$mediaStatus" == "No player could handle this command" ]]; then
echo "N/A"
else
status=$(playerctl --player=playerctld metadata --format '{{ status }}')
echo $status
fi

View File

@@ -1,7 +0,0 @@
#!/usr/bin/env bash
profile="$(sudo system76-power profile | sed -z '$ s/\n$//' | tr '\n' '\r')"
graphics="$(sudo system76-power graphics)"
graphicsPower="$(sudo system76-power graphics power)"
chargeThresholds="$(sudo system76-power charge-thresholds | sed -z '$ s/\n$//' | tr '\n' '\r')"
echo '{"text":"󰢮 '$graphics'","tooltip":"󰢮\t'$graphics'\r󰐥\t'$graphicsPower'\r\r Profile\r'$profile'\r\r󰚥 Charge Thresholds\r'$chargeThresholds'"}'

View File

@@ -1,190 +0,0 @@
window#waybar {
background: transparent;
}
#window {
padding: 0px 0px;
color: transparent;
background: transparent;
}
widget {
background: #282a36;
border-radius: 25px;
}
label.module {
padding: 0px 10px;
}
button {
border-radius: 0px;
padding: 0px 0px;
}
.module,button {
font-size: 15px;
font-family: Ubuntu Nerd Font;
}
#battery {
background: transparent;
color: #ff79c6;
}
#cpu {
background: transparent;
color: #ffb86c;
}
#clock {
background: transparent;
color: #bd93f9;
}
box#dunst {
padding: 0px 10px;
}
#custom-dunst-status {
background: transparent;
color: #50fa7b;
padding: 0px 5px;
}
#custom-dunst-clear {
background: transparent;
color: #50fa7b;
padding: 0px 5px;
}
#custom-dunst-history-view {
background: transparent;
color: #50fa7b;
padding: 0px 5px;
}
#custom-dunst-history-clear {
background: transparent;
color: #50fa7b;
padding: 0px 5px;
}
#tags {
padding: 0px 10px;
}
#tags button {
background: transparent;
color: #44475a;
padding: 0px 5px;
}
#tags button.occupied {
background: transparent;
color: #f1fa8c;
}
#tags button.focused {
background: transparent;
box-shadow: inset 0 -3px #bd93f9;
}
#tags button.urgent {
background: transparent;
color: #ff5555;
}
#window.title {
background: transparent;
color: #f8f8f2;
padding: 0px 10px;
}
#window.layout {
background: transparent;
color: #50fa7b;
padding: 0px 10px;
}
#disk {
background: transparent;
color: #f1fa8c;
}
#idle_inhibitor.activated {
background: transparent;
color: #f1fa8c;
}
#idle_inhibitor.deactivated {
background: transparent;
color: #44475a;
}
#memory {
background: transparent;
color: #8be9fd;
}
box#media-playing {
padding: 0px 10px;
}
#custom-media-playing-source {
background: transparent;
color: #ff5555;
padding: 0px 5px;
}
#custom-media-playing-prev {
background: transparent;
color: #ff5555;
padding: 0px 5px;
}
#custom-media-playing-play-pause {
background: transparent;
color: #ff5555;
padding: 0px 5px;
}
#custom-media-playing-next {
background: transparent;
color: #ff5555;
padding: 0px 5px;
}
box#power-menu {
padding: 0px 10px;
}
#custom-power-menu-launcher {
background: transparent;
color: #8be9fd;
padding: 0px 5px;
}
#custom-power-menu-shutdown {
background: transparent;
color: #ff5555;
padding: 0px 5px;
}
#custom-power-menu-reboot {
background: transparent;
color: #50fa7b;
padding: 0px 5px;
}
#custom-power-menu-sleep {
background: transparent;
color: #f1fa8c;
padding: 0px 5px;
}
#custom-power-menu-lock {
background: transparent;
color: #ff79c6;
padding: 0px 5px;
}
#custom-power-menu-logout {
background: transparent;
color: #ffb86c;
padding: 0px 5px;
}
#pulseaudio {
background: transparent;
color: #ff79c6;
}
#custom-system76-power {
background: transparent;
color: #50fa7b;
}
#tray {
background: transparent;
padding: 0px 10px;
}