Compare commits

...

12 Commits

Author SHA1 Message Date
Sravan Balaji
d2e550ceb3 Disable term and menu keybindings (using swhkd instead) 2024-09-28 15:59:37 -04:00
Sravan Balaji
5b32793886 Add swhkd startup processes to autostart 2024-09-28 15:28:28 -04:00
Sravan Balaji
95f75e3e5b Fix Waybar Font and Icon Spacing 2024-09-28 11:15:41 -04:00
Sravan Balaji
0f3b21946c Update waybar configuration and styling 2024-09-28 10:35:09 -04:00
Sravan Balaji
1ee3be772c Add waybar configuration and autostart 2024-09-27 21:40:01 -04:00
Sravan Balaji
57b6564f2f Add waybar to autostart 2024-09-27 20:42:08 -04:00
Sravan Balaji
6c254789eb Add unclutter patch 2024-09-27 20:20:39 -04:00
Sravan Balaji
1ad3cc58e0 Add missing pre-processor directives to config.def.h 2024-09-27 20:04:05 -04:00
Sravan Balaji
80ae662f24 Add float unfocused border color patch 2024-09-27 20:03:44 -04:00
Sravan Balaji
c385bd6f4c Add alwayscenterp patch 2024-09-27 19:55:06 -04:00
Sravan Balaji
d89e40ddaa Fix space / tab inconsistency 2024-09-27 19:46:18 -04:00
Sravan Balaji
089bb41dab Add setupenv patch 2024-09-22 21:43:45 -04:00
12 changed files with 1110 additions and 75 deletions

View File

@@ -1,4 +1,4 @@
#+TITLE: Personal dwl Configuration
#+TITLE: Personal dwl Configuration with Waybar
#+AUTHOR: Sravan Balaji
#+AUTO_TANGLE: t
#+STARTUP: showeverything
@@ -6,30 +6,50 @@
* Table of Contents :TOC_3:noexport:
- [[#welcome][Welcome]]
- [[#dwl---dwm-for-wayland][dwl - dwm for Wayland]]
- [[#patches][Patches]]
- [[#attach-top][Attach Top]]
- [[#auto-start][Auto Start]]
- [[#foreign-toplevel-management][Foreign Toplevel Management]]
- [[#ipc][IPC]]
- [[#natural-scroll-trackpad][Natural Scroll Trackpad]]
- [[#numlock-capslock][Numlock Capslock]]
- [[#per-tag][Per Tag]]
- [[#restore-monitor][Restore Monitor]]
- [[#vanity-gaps][Vanity Gaps]]
- [[#warp-cursor][Warp Cursor]]
- [[#dwl-configuration][dwl Configuration]]
- [[#appearance][Appearance]]
- [[#tagging][Tagging]]
- [[#logging][Logging]]
- [[#autostart][Autostart]]
- [[#window-rules][Window Rules]]
- [[#layouts][Layouts]]
- [[#monitor-rules][Monitor Rules]]
- [[#keyboard][Keyboard]]
- [[#trackpad][Trackpad]]
- [[#keybindings][Keybindings]]
- [[#commands][Commands]]
- [[#buttons][Buttons]]
- [[#patches][Patches]]
- [[#always-center][Always Center]]
- [[#attach-top][Attach Top]]
- [[#auto-start][Auto Start]]
- [[#float-unfocused-border-color][Float Unfocused Border Color]]
- [[#foreign-toplevel-management][Foreign Toplevel Management]]
- [[#ipc][IPC]]
- [[#natural-scroll-trackpad][Natural Scroll Trackpad]]
- [[#numlock-capslock][Numlock Capslock]]
- [[#per-tag][Per Tag]]
- [[#restore-monitor][Restore Monitor]]
- [[#setup-env][Setup Env]]
- [[#unclutter][Unclutter]]
- [[#vanity-gaps][Vanity Gaps]]
- [[#warp-cursor][Warp Cursor]]
- [[#configuration][Configuration]]
- [[#appearance][Appearance]]
- [[#tagging][Tagging]]
- [[#logging][Logging]]
- [[#environment-variables][Environment Variables]]
- [[#autostart][Autostart]]
- [[#window-rules][Window Rules]]
- [[#layouts][Layouts]]
- [[#monitor-rules][Monitor Rules]]
- [[#keyboard][Keyboard]]
- [[#trackpad][Trackpad]]
- [[#keybindings][Keybindings]]
- [[#commands][Commands]]
- [[#buttons][Buttons]]
- [[#waybar][Waybar]]
- [[#start-configuration][Start Configuration]]
- [[#bar][Bar]]
- [[#configuration-1][Configuration]]
- [[#styling][Styling]]
- [[#modules][Modules]]
- [[#battery][battery]]
- [[#cpu][cpu]]
- [[#clock][clock]]
- [[#dwltags][dwl/tags]]
- [[#disk][disk]]
- [[#memory][memory]]
- [[#pulseaudio][pulseaudio]]
- [[#tray][tray]]
- [[#end-configuration][End Configuration]]
- [[#justfile][Justfile]]
* Welcome
@@ -53,9 +73,17 @@ sudo make clean install
See [[./README.md][Upstream README]] for details on project.
* Patches
** Patches
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/attachtop][Attach Top]]
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/alwayscenter][Always Center]]
Automatically center floating windows.
#+BEGIN_SRC c :tangle patches.def.h
#define ALWAYSCENTER_PATCH 1
#+END_SRC
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/attachtop][Attach Top]]
This is a port of attachtop patch for dwm: https://dwm.suckless.org/patches/attachtop
@@ -67,7 +95,7 @@ Behavior feels very intuitive as it doesn't disrupt existing masters no matter t
#define ATTACHTOP_PATCH 1
#+END_SRC
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/autostart][Auto Start]]
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/autostart][Auto Start]]
Allow dwl to execute commands from autostart array in your config.h file. And when you exit dwl all processes from autostart array will be killed.
@@ -77,7 +105,17 @@ Note: Commands from array are executed using execvp(). So if you need to execute
#define AUTOSTART_PATCH 1
#+END_SRC
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/foreign-toplevel-management][Foreign Toplevel Management]]
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/float-unfocused-border-color][Float Unfocused Border Color]]
A revive of the floatBorderColor patch.
This patch allows you to set a color for floating windows when they are unfocused.
#+BEGIN_SRC c :tangle patches.def.h
#define FLOAT_UNFOCUSED_BORDER_COLOR_PATCH 1
#+END_SRC
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/foreign-toplevel-management][Foreign Toplevel Management]]
Implement ~foreign-toplevel-management~, it add handlers for activate, close, fullscreen and destroy request events, it's missing minimize and maximize request handlers.
@@ -85,7 +123,7 @@ Implement ~foreign-toplevel-management~, it add handlers for activate, close, fu
#define FOREIGN_TOPLEVEL_MANAGEMENT_PATCH 1
#+END_SRC
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/ipc][IPC]]
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/ipc][IPC]]
Largely based on [[https://sr.ht/~raphi/][raphi]]'s [[https://sr.ht/~raphi/somebar/][somebar]], this patch provides an ipc for wayland clients to get and set dwl state. The ipc is intended for status bars, but can also be scripted with tools like [[https://codeberg.org/notchoc/dwlmsg][dwlmsg]].
@@ -97,7 +135,7 @@ Note to [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/pertag][p
#define IPC_PATCH 1
#+END_SRC
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/naturalscrolltrackpad][Natural Scroll Trackpad]]
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/naturalscrolltrackpad][Natural Scroll Trackpad]]
Set natural scrolling only for trackpads.
@@ -105,7 +143,7 @@ Set natural scrolling only for trackpads.
#define NATURALSCROLLTRACKPAD_PATCH 1
#+END_SRC
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/numlock-capslock][Numlock Capslock]]
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/numlock-capslock][Numlock Capslock]]
Allows activating numlock or capslock at startup.
@@ -113,7 +151,7 @@ Allows activating numlock or capslock at startup.
#define NUMLOCK_CAPSLOCK_PATCH 1
#+END_SRC
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/pertag][Per Tag]]
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/pertag][Per Tag]]
Makes layout, mwfact and nmaster individual for every tag.
@@ -121,7 +159,7 @@ Makes layout, mwfact and nmaster individual for every tag.
#define PERTAG_PATCH 1
#+END_SRC
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/restore-monitor][Restore Monitor]]
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/restore-monitor][Restore Monitor]]
Moves clients to their old output when it is reattached.
@@ -129,7 +167,23 @@ Moves clients to their old output when it is reattached.
#define RESTORE_MONITOR_PATCH 1
#+END_SRC
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/vanitygaps][Vanity Gaps]]
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/setupenv][Setup Env]]
Allow configuring environment variables in config.h
#+BEGIN_SRC c :tangle patches.def.h
#define SETUPENV_PATCH 1
#+END_SRC
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/unclutter][Unclutter]]
Hide the mouse cursor if it isn't being used for a certain period of time.
#+BEGIN_SRC c :tangle patches.def.h
#define UNCLUTTER_PATCH 1
#+END_SRC
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/vanitygaps][Vanity Gaps]]
Adds (inner) gaps between client windows and (outer) gaps between windows and the screen edge in a flexible manner.
@@ -137,7 +191,7 @@ Adds (inner) gaps between client windows and (outer) gaps between windows and th
#define VANITYGAPS_PATCH 1
#+END_SRC
** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/warpcursor][Warp Cursor]]
*** [[https://codeberg.org/dwl/dwl-patches/src/branch/main/patches/warpcursor][Warp Cursor]]
Warp cursor to the centre of newly focused clients.
@@ -149,11 +203,11 @@ This is my version of the orphaned cursorwarp patch except I left out the config
#define WARPCURSOR_PATCH 1
#+END_SRC
* dwl Configuration
** Configuration
Taken from https://github.com/djpohly/dwl/issues/466.
** Appearance
*** Appearance
#+BEGIN_SRC c :tangle config.h
#define COLOR(hex) { ((hex >> 24) & 0xFF) / 255.0f, \
@@ -180,33 +234,56 @@ 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 */
#+END_SRC
** Tagging
*** Tagging
#+BEGIN_SRC c :tangle config.h
/* tagging - TAGCOUNT must be no greater than 31 */
#define TAGCOUNT (9)
#+END_SRC
** Logging
*** Logging
#+BEGIN_SRC c :tangle config.h
static int log_level = WLR_ERROR;
#+END_SRC
** Autostart
*** Environment Variables
#+BEGIN_SRC c :tangle config.h
#if SETUPENV_PATCH
static const Env envs[] = {
/* 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
#+END_SRC
*** Autostart
#+BEGIN_SRC c :tangle config.h
#if AUTOSTART_PATCH
static const char *const autostart[] = {
/* Display / Compositor Setup */
"/usr/bin/shikane", NULL,
"/usr/bin/waybar", "-c", "/home/sravan/.config/dwl/waybar/config.jsonc", "-s", "/home/sravan/.config/dwl/waybar/style.css", NULL,
"/usr/bin/bash", "/home/sravan/.azotebg", NULL,
"/usr/bin/gammastep", "-x", NULL,
/* Background Processes */
"/usr/bin/swhks", NULL,
"/usr/bin/swhkd", NULL,
"/usr/libexec/polkit-gnome-authentication-agent-1", NULL,
"/usr/bin/kdeconnectd", "--replace", NULL,
"/usr/bin/bash", "/home/sravan/.scripts/dunst.sh", "--on", NULL,
@@ -228,7 +305,7 @@ static const char *const autostart[] = {
#endif // AUTOSTART_PATCH
#+END_SRC
** Window Rules
*** Window Rules
#+BEGIN_SRC c :tangle config.h
/* NOTE: ALWAYS keep a rule declared even if you don't use rules (e.g leave at least one example) */
@@ -240,7 +317,7 @@ static const Rule rules[] = {
};
#+END_SRC
** Layouts
*** Layouts
#+BEGIN_SRC c :tangle config.h
static const Layout layouts[] = {
@@ -251,7 +328,7 @@ static const Layout layouts[] = {
};
#+END_SRC
** Monitor Rules
*** Monitor Rules
#+BEGIN_SRC c :tangle config.h
/* (x=-1, y=-1) is reserved as an "autoconfigure" monitor position indicator
@@ -269,7 +346,7 @@ static const MonitorRule monrules[] = {
};
#+END_SRC
** Keyboard
*** Keyboard
#+BEGIN_SRC c :tangle config.h
static const struct xkb_rule_names xkb_rules = {
@@ -290,7 +367,7 @@ static const int repeat_rate = 25;
static const int repeat_delay = 600;
#+END_SRC
** Trackpad
*** Trackpad
#+BEGIN_SRC c :tangle config.h
static const int tap_to_click = 1;
@@ -300,6 +377,9 @@ 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
@@ -337,7 +417,7 @@ 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;
#+END_SRC
** Keybindings
*** Keybindings
#+BEGIN_SRC c :tangle config.h
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
@@ -353,7 +433,7 @@ static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TA
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
#+END_SRC
** Commands
*** Commands
#+BEGIN_SRC c :tangle config.h
static const char *termcmd[] = { "kitty", NULL };
@@ -362,8 +442,8 @@ static const char *menucmd[] = { "rofi", "-show", "combi", NULL };
static const Key keys[] = {
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
/* modifier key function argument */
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
// { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
// { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
#if IPC_PATCH
{ MODKEY, XKB_KEY_b, togglebar, {0} },
#endif // IPC_PATCH
@@ -428,7 +508,7 @@ static const Key keys[] = {
};
#+END_SRC
** Buttons
*** Buttons
#+BEGIN_SRC c :tangle config.h
static const Button buttons[] = {
@@ -438,6 +518,272 @@ static const Button buttons[] = {
};
#+END_SRC
* Waybar
** Start Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
// -*- mode: jsonc -*-
{
#+END_SRC
** Bar
*** Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.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
// Choose the order of the modules
"spacing": 4, // Gaps between modules (4px)
"mode": "dock",
"start_hidden": false,
"fixed-center": true,
"reload_style_on_change": true,
"modules-left": [
"dwl/tags",
],
"modules-center": [
"tray",
],
"modules-right": [
"pulseaudio",
"cpu",
"memory",
"disk",
"battery",
"clock"
],
#+END_SRC
*** Styling
#+BEGIN_SRC css :tangle waybar/style.css
window#waybar {
background: #282a36;
}
.module {
border-radius: 25px;
padding: 0px 3px;
font-size: 15px;
font-family: Ubuntu Nerd Font
}
#+END_SRC
** Modules
*** battery
**** Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
"battery": {
"interval": 60,
"format": "{icon} {capacity}%",
"format-icons": ["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"],
"tooltip": true,
"tooltip-format": "󱧥\t{timeTo}\n󱐋\t{power} W\n󱠴\t{cycles}\n󱈏\t{health}%",
},
#+END_SRC
**** Styling
#+BEGIN_SRC css :tangle waybar/style.css
#battery {
background: #50fa7b;
color: #282a36;
}
#+END_SRC
*** cpu
**** Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
"cpu": {
"interval": 5,
"format": " {usage}%",
"tooltip": true,
},
#+END_SRC
**** Styling
#+BEGIN_SRC css :tangle waybar/style.css
#cpu {
background: #bd93f9;
color: #282a36;
}
#+END_SRC
*** clock
**** Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
"clock": {
"interval": 60,
"format": "󰥔 {:%H:%M}"
},
#+END_SRC
**** Styling
#+BEGIN_SRC css :tangle waybar/style.css
#clock {
background: #bd93f9;
color: #282a36;
}
#+END_SRC
*** dwl/tags
**** Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
"dwl/tags": {
"num-tags": 9,
"tag-labels": [ "󰍩 ₁", "󰠮 ₂", " ₃", "󰿎 ₄", "󰖟 ₅", " ₆", "󰊢 ₇", "󰊖 ₈", " ₉" ],
"disable-click": false
},
#+END_SRC
**** Styling
#+BEGIN_SRC css :tangle waybar/style.css
#tags {
color: #f8f8f2;
background: #44475a;
}
#tags button {
margin-left: 3px;
margin-right: 3px;
padding: 0px 3px;
}
#tags button.occupied {
background: #f1fa8c;
color: #282a36;
}
#tags button.focused {
background: #bd93f9;
color: #282a36;
}
#tags button.urgent {
background: #ff5555;
color: #282a36;
}
#+END_SRC
*** disk
**** Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
"disk": {
"interval": 60,
"format": "󰋊 {percentage_used}%",
"tooltip": true,
"tooltip-format": "Used: {used} ({percentage_used}%)\nFree: {free} ({percentage_free}%)\nTotal: {total}",
},
#+END_SRC
**** Styling
#+BEGIN_SRC css :tangle waybar/style.css
#disk {
color: #282a36;
background: #ff79c6;
}
#+END_SRC
*** memory
**** Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
"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",
},
#+END_SRC
**** Styling
#+BEGIN_SRC css :tangle waybar/style.css
#memory {
color: #282a36;
background: #8be9fd;
}
#+END_SRC
*** pulseaudio
**** Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
"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": "pavucontrol",
"tooltip": true,
"tooltip-format": "{desc}",
},
#+END_SRC
**** Styling
#+BEGIN_SRC css :tangle waybar/style.css
#pulseaudio {
color: #282a36;
background: #ff5555;
}
#+END_SRC
*** tray
**** Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
"tray": {
"icon-size": 21,
"show-passive-items": true,
"spacing": 4,
"reverse-direction": false,
},
#+END_SRC
**** Styling
#+BEGIN_SRC css :tangle waybar/style.css
#tray {
background: #44475a;
}
#+END_SRC
** End Configuration
#+BEGIN_SRC jsonc :tangle waybar/config.jsonc
}
#+END_SRC
* Justfile
#+BEGIN_SRC just :tangle justfile
@@ -450,4 +796,8 @@ default:
# Rebuild project
dwl-rebuild:
sudo make clean all
# Run waybar with dwl configuration
dwl-launch-waybar:
/usr/bin/waybar -c /home/sravan/.config/dwl/waybar/config.jsonc -s /home/sravan/.config/dwl/waybar/style.css
#+END_SRC

View File

@@ -6,17 +6,24 @@
/* 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 */
@@ -26,12 +33,20 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* logging */
static int log_level = WLR_ERROR;
#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 */
};
#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[] = {
@@ -90,6 +105,9 @@ 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
@@ -155,6 +173,7 @@ static const Key keys[] = {
{ 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 } },
@@ -171,6 +190,7 @@ 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} },

View File

@@ -20,6 +20,9 @@ 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 */
@@ -28,13 +31,30 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
static int log_level = WLR_ERROR;
#if SETUPENV_PATCH
static const Env envs[] = {
/* 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[] = {
/* Display / Compositor Setup */
"/usr/bin/shikane", NULL,
"/usr/bin/waybar", "-c", "/home/sravan/.config/dwl/waybar/config.jsonc", "-s", "/home/sravan/.config/dwl/waybar/style.css", NULL,
"/usr/bin/bash", "/home/sravan/.azotebg", NULL,
"/usr/bin/gammastep", "-x", NULL,
/* Background Processes */
"/usr/bin/swhks", NULL,
"/usr/bin/swhkd", NULL,
"/usr/libexec/polkit-gnome-authentication-agent-1", NULL,
"/usr/bin/kdeconnectd", "--replace", NULL,
"/usr/bin/bash", "/home/sravan/.scripts/dunst.sh", "--on", NULL,
@@ -108,6 +128,9 @@ 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
@@ -162,8 +185,8 @@ static const char *menucmd[] = { "rofi", "-show", "combi", NULL };
static const Key keys[] = {
/* Note that Shift changes certain key codes: c -> C, 2 -> at, etc. */
/* modifier key function argument */
{ MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
// { MODKEY, XKB_KEY_p, spawn, {.v = menucmd} },
// { MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Return, spawn, {.v = termcmd} },
#if IPC_PATCH
{ MODKEY, XKB_KEY_b, togglebar, {0} },
#endif // IPC_PATCH

170
dwl.c
View File

@@ -276,6 +276,13 @@ typedef struct {
int monitor;
} Rule;
#if SETUPENV_PATCH
typedef struct {
const char *variable;
const char *value;
} Env;
#endif // SETUPENV_PATCH
typedef struct {
struct wlr_scene_tree *scene;
@@ -353,6 +360,10 @@ 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 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
@@ -488,6 +499,16 @@ 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;
@@ -606,6 +627,14 @@ 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);
}
@@ -741,6 +770,9 @@ 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. */
@@ -759,6 +791,9 @@ 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:
@@ -791,6 +826,9 @@ 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;
@@ -895,7 +933,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);
@@ -1892,9 +1930,13 @@ 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);
@@ -2045,9 +2087,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) {
@@ -2055,6 +2097,34 @@ 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)
{
@@ -2366,7 +2436,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);
@@ -2376,6 +2446,12 @@ 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);
@@ -2431,8 +2507,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)
@@ -2511,6 +2587,9 @@ 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)
@@ -2535,7 +2614,11 @@ 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);
@@ -2880,6 +2963,10 @@ run(char *startup_cmd)
if (!socket)
die("startup: display_add_socket_auto");
setenv("WAYLAND_DISPLAY", socket, 1);
#if SETUPENV_PATCH
for (size_t i = 0; i < LENGTH(envs); i++)
setenv(envs[i].variable, envs[i].value, 1);
#endif // SETUPENV_PATCH
/* Start the backend. This will enumerate outputs and inputs, become the DRM
* master, etc */
@@ -2926,6 +3013,9 @@ 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
@@ -2949,9 +3039,22 @@ 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
@@ -2963,9 +3066,20 @@ 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
@@ -2979,6 +3093,13 @@ 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();
}
@@ -3089,15 +3210,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);
@@ -3305,6 +3426,11 @@ 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,
@@ -3404,8 +3530,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
}
@@ -3444,8 +3570,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)
@@ -3458,9 +3584,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
@@ -3470,9 +3596,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++;
@@ -3765,7 +3891,6 @@ 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 */
@@ -3824,6 +3949,9 @@ 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

View File

@@ -7,3 +7,7 @@ default:
# Rebuild project
dwl-rebuild:
sudo make clean all
# Run waybar with dwl configuration
dwl-launch-waybar:
/usr/bin/waybar -c /home/sravan/.config/dwl/waybar/config.jsonc -s /home/sravan/.config/dwl/waybar/style.css

View File

@@ -1,7 +1,11 @@
#define ALWAYSCENTER_PATCH 1
#define ATTACHTOP_PATCH 1
#define AUTOSTART_PATCH 1
#define FLOAT_UNFOCUSED_BORDER_COLOR_PATCH 1
#define FOREIGN_TOPLEVEL_MANAGEMENT_PATCH 1
#define IPC_PATCH 1
@@ -14,6 +18,10 @@
#define RESTORE_MONITOR_PATCH 1
#define SETUPENV_PATCH 1
#define UNCLUTTER_PATCH 1
#define VANITYGAPS_PATCH 1
#define WARPCURSOR_PATCH 1

View File

@@ -0,0 +1,38 @@
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

@@ -0,0 +1,60 @@
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

@@ -0,0 +1,54 @@
From 11ee2fc23ef5728d1e132f338c08a7805c6109b2 Mon Sep 17 00:00:00 2001
From: choc <notchoc@proton.me>
Date: Tue, 26 Mar 2024 21:02:16 +0800
Subject: [PATCH] implement setupenv
---
config.def.h | 5 +++++
dwl.c | 7 +++++++
2 files changed, 12 insertions(+)
diff --git a/config.def.h b/config.def.h
index 9009517..b16189a 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,6 +20,11 @@ static const float fullscreen_bg[] = {0.1f, 0.1f, 0.1f, 1.0f}; /* You ca
/* logging */
static int log_level = WLR_ERROR;
+static const Env envs[] = {
+ /* variable value */
+ { "XDG_CURRENT_DESKTOP", "wlroots" },
+};
+
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
/* examples:
diff --git a/dwl.c b/dwl.c
index 5867b0c..b7d522b 100644
--- a/dwl.c
+++ b/dwl.c
@@ -230,6 +230,11 @@ typedef struct {
int monitor;
} Rule;
+typedef struct {
+ const char *variable;
+ const char *value;
+} Env;
+
typedef struct {
struct wlr_scene_tree *scene;
@@ -2066,6 +2071,8 @@ run(char *startup_cmd)
if (!socket)
die("startup: display_add_socket_auto");
setenv("WAYLAND_DISPLAY", socket, 1);
+ for (size_t i = 0; i < LENGTH(envs); i++)
+ setenv(envs[i].variable, envs[i].value, 1);
/* Start the backend. This will enumerate outputs and inputs, become the DRM
* master, etc */
--
2.44.0

View File

@@ -0,0 +1,188 @@
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

96
waybar/config.jsonc Normal file
View File

@@ -0,0 +1,96 @@
// -*- 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
// Choose the order of the modules
"spacing": 4, // Gaps between modules (4px)
"mode": "dock",
"start_hidden": false,
"fixed-center": true,
"reload_style_on_change": true,
"modules-left": [
"dwl/tags",
],
"modules-center": [
"tray",
],
"modules-right": [
"pulseaudio",
"cpu",
"memory",
"disk",
"battery",
"clock"
],
"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,
},
"clock": {
"interval": 60,
"format": "󰥔 {:%H:%M}"
},
"dwl/tags": {
"num-tags": 9,
"tag-labels": [ "󰍩 ₁", "󰠮 ₂", " ₃", "󰿎 ₄", "󰖟 ₅", " ₆", "󰊢 ₇", "󰊖 ₈", " ₉" ],
"disable-click": false
},
"disk": {
"interval": 60,
"format": "󰋊 {percentage_used}%",
"tooltip": true,
"tooltip-format": "Used: {used} ({percentage_used}%)\nFree: {free} ({percentage_free}%)\nTotal: {total}",
},
"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",
},
"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": "pavucontrol",
"tooltip": true,
"tooltip-format": "{desc}",
},
"tray": {
"icon-size": 21,
"show-passive-items": true,
"spacing": 4,
"reverse-direction": false,
},
}

66
waybar/style.css Normal file
View File

@@ -0,0 +1,66 @@
window#waybar {
background: #282a36;
}
.module {
border-radius: 25px;
padding: 0px 3px;
font-size: 15px;
font-family: Ubuntu Nerd Font
}
#battery {
background: #50fa7b;
color: #282a36;
}
#cpu {
background: #bd93f9;
color: #282a36;
}
#clock {
background: #bd93f9;
color: #282a36;
}
#tags {
color: #f8f8f2;
background: #44475a;
}
#tags button {
margin-left: 3px;
margin-right: 3px;
padding: 0px 3px;
}
#tags button.occupied {
background: #f1fa8c;
color: #282a36;
}
#tags button.focused {
background: #bd93f9;
color: #282a36;
}
#tags button.urgent {
background: #ff5555;
color: #282a36;
}
#disk {
color: #282a36;
background: #ff79c6;
}
#memory {
color: #282a36;
background: #8be9fd;
}
#pulseaudio {
color: #282a36;
background: #ff5555;
}
#tray {
background: #44475a;
}