Skip to content

Commit

Permalink
Basic setup
Browse files Browse the repository at this point in the history
  • Loading branch information
CharaD7 committed Oct 7, 2024
0 parents commit 7893063
Show file tree
Hide file tree
Showing 45 changed files with 10,807 additions and 0 deletions.
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# dwm - dynamic window manager
# See LICENSE file for copyright and license details.

include config.mk

SRC = drw.c dwm.c util.c
OBJ = ${SRC:.c=.o}

all: options dwm

options:
@echo dwm build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "CC = ${CC}"

.c.o:
${CC} -c ${CFLAGS} $<

${OBJ}: config.h config.mk

config.h:
cp config.def.h $@

dwm: ${OBJ}
${CC} -o $@ ${OBJ} ${LDFLAGS}

clean:
rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz config.h

dist: clean
mkdir -p dwm-${VERSION}
cp -R LICENSE Makefile README config.def.h config.mk\
dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION}
tar -cf dwm-${VERSION}.tar dwm-${VERSION}
gzip dwm-${VERSION}.tar
rm -rf dwm-${VERSION}

install: all
mkdir -p ${DESTDIR}${PREFIX}/bin
cp -f dwm ${DESTDIR}${PREFIX}/bin
chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
mkdir -p ${DESTDIR}${MANPREFIX}/man1
sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1

uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/dwm\
${DESTDIR}${MANPREFIX}/man1/dwm.1

.PHONY: all options clean dist install uninstall
338 changes: 338 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,338 @@
/* See LICENSE file for copyright and license details. */

#include <X11/XF86keysym.h>

/* appearance */
static const unsigned int borderpx = 1; /* border pixel of windows */
static const unsigned int default_border = 0; /* to switch back to default border after dynamic border resizing via keybinds */
static const unsigned int snap = 32; /* snap pixel */
static const unsigned int gappih = 5; /* horiz inner gap between windows */
static const unsigned int gappiv = 5; /* vert inner gap between windows */
static const unsigned int gappoh = 5; /* horiz outer gap between windows and screen edge */
static const unsigned int gappov = 5; /* vert outer gap between windows and screen edge */
static const int smartgaps = 0; /* 1 means no outer gap when there is only one window */
static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */
static const unsigned int systrayspacing = 2; /* systray spacing */
static const int systraypinningfailfirst = 1; /* 1: if pinning fails,display systray on the 1st monitor,False: display systray on last monitor*/
static const int showsystray = 1; /* 0 means no systray */
static const int showbar = 1; /* 0 means no bar */
static const int showtab = showtab_auto;
static const int toptab = 1; /* 0 means bottom tab */
static const int floatbar = 1; /* 1 means the bar will float(don't have padding),0 means the bar have padding */
static const int topbar = 1; /* 0 means bottom bar */
static const int horizpadbar = 5;
static const int vertpadbar = 11;
static const int vertpadtab = 35;
static const int horizpadtabi = 15;
static const int horizpadtabo = 15;
static const int tag_preview = 1; /* 1 means enable, 0 is off */
static const int scalepreview = 4;
static const int colorfultag = 1; /* 0 means use SchemeSel for selected non vacant tag */
static const char *upvol[] = {"/usr/bin/pactl", "set-sink-volume", "0", "+5%", NULL};
static const char *downvol[] = {"/usr/bin/pactl", "set-sink-volume", "0", "-5%", NULL};
static const char *mutevol[] = {"/usr/bin/pactl", "set-sink-mute", "0", "toggle", NULL};
static const char *light_up[] = {"/usr/bin/light", "-A", "5", NULL};
static const char *light_down[] = {"/usr/bin/light", "-U", "5", NULL};
static const int new_window_attach_on_end = 1; /* 1 means the new window will attach on the end; 0 means the new window will attach on the front,default is front */
#define ICONSIZE 22 /* icon size */
#define ICONSPACING 3 /* space between icon and title */

static const char *fonts[] = {"Iosevka:style:medium:size=10",
"Fira Code iScript:style:medium:size=10"};
/*static const char *fonts[] = {*/
/* "Iosevka:style:medium:size=10",*/
/* "JetBrainsMono Nerd Font Mono:style:medium:size=8"};*/

// theme
/*#include "themes/onedark.h"*/
#include "themes/catppuccin.h"

static const char *colors[][3] = {
/* fg bg border */
[SchemeNorm] = {gray3, black, gray3},
[SchemeSel] = {gray4, blue, blue},
[SchemeTitle] = {white, black, black}, // active window title
[TabSel] = {blue, gray2, black},
[TabNorm] = {gray3, black, black},
[SchemeTag] = {gray3, black, gray3},
[SchemeTag1] = {blue, black, blue},
[SchemeTag2] = {red, black, red},
[SchemeTag3] = {orange, black, orange},
[SchemeTag4] = {green, black, green},
[SchemeTag5] = {pink, black, pink},
[SchemeTag6] = {turquoise, black, turquoise},
[SchemeTag7] = {goldenrod, black, goldenrod},
[SchemeTag8] = {tan, black, tan},
[SchemeTag9] = {almond, black, almond},
[SchemeLayout] = {green, black, black},
[SchemeBtnPrev] = {green, black, black},
[SchemeBtnNext] = {yellow, black, black},
[SchemeBtnClose] = {red, black, black},
};

/* tagging */
static char *tags[] = {"󰞷", "󰈹", "󰹼", "󱞊", "󱛉",
"󱃖", "󰐤", "󰀼", "󰅢"};

static const char *eww[] = {"eww", "open", "eww", NULL};

static const Launcher launchers[] = {
/* command name to display */
{eww, "󰭛"},
};

static const int tagschemes[] = {SchemeTag1, SchemeTag2, SchemeTag3, SchemeTag4,
SchemeTag5, SchemeTag6, SchemeTag7, SchemeTag8,
SchemeTag9};

static const unsigned int ulinepad =
5; /* horizontal padding between the underline and tag */
static const unsigned int ulinestroke =
2; /* thickness / height of the underline */
static const unsigned int ulinevoffset =
0; /* how far above the bottom of the bar the line should appear */
static const int ulineall =
0; /* 1 to show underline on all tags, 0 for just the active ones */

static const Rule rules[] = {
/* xprop(1):
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
/* class instance title tags mask iscentered isfloating
monitor */
{"Gimp", NULL, NULL, 0, 0, 1, -1},
{"Firefox", NULL, NULL, 1 << 8, 0, 0, -1},
{"eww", NULL, NULL, 0, 0, 1, -1},
};

/* layout(s) */
static const float mfact = 0.50; /* factor of master area size [0.05..0.95] */
static const int nmaster = 1; /* number of clients in master area */
static const int resizehints =
0; /* 1 means respect size hints in tiled resizals */
static const int lockfullscreen =
1; /* 1 will force focus on the fullscreen window */

#define FORCE_VSPLIT \
1 /* nrowgrid layout: force two clients to always split vertically */
#include "functions.h"

static const Layout layouts[] = {
/* symbol arrange function */
{"[]=", tile}, /* first entry is default */
{"[M]", monocle},
{"[@]", spiral},
{"[\\]", dwindle},
{"H[]", deck},
{"TTT", bstack},
{"===", bstackhoriz},
{"HHH", grid},
{"###", nrowgrid},
{"---", horizgrid},
{":::", gaplessgrid},
{"|M|", centeredmaster},
{">M>", centeredfloatingmaster},
{"><>", NULL}, /* no layout function means floating behavior */
{NULL, NULL},
};

/* key definitions */
#define MODKEY Mod4Mask
#define TAGKEYS(KEY, TAG) \
{MODKEY, KEY, view, {.ui = 1 << TAG}}, \
{MODKEY | ControlMask, KEY, toggleview, {.ui = 1 << TAG}}, \
{MODKEY | ShiftMask, KEY, tag, {.ui = 1 << TAG}}, \
{MODKEY | ControlMask | ShiftMask, KEY, toggletag, {.ui = 1 << TAG}},

/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) \
{ \
.v = (const char *[]) { "/bin/sh", "-c", cmd, NULL } \
}

/* commands */

static const Key keys[] = {
/* modifier key function argument */

// brightness and audio
{0, XF86XK_AudioLowerVolume, spawn, {.v = downvol}},
{0, XF86XK_AudioMute, spawn, {.v = mutevol}},
{0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol}},
{0, XF86XK_MonBrightnessUp, spawn, {.v = light_up}},
{0, XF86XK_MonBrightnessDown, spawn, {.v = light_down}},

// keyboard backlight
// keylight is a an alias for backlight located in the scripts directory
{MODKEY | Mod1Mask, XK_b, spawn, SHCMD("./scripts/backlight")},

// screenshot fullscreen and cropped
{MODKEY | ControlMask, XK_u, spawn,
SHCMD("maim | xclip -selection clipboard -t image.png")},
{MODKEY, XK_u, spawn,
SHCMD("maim --select | xclip -selection clipboard -t image.png")},

{MODKEY, XK_c, spawn, SHCMD("rofi -show drun")},
{MODKEY, XK_r, spawn, SHCMD("rofi -show run")},
{MODKEY, XK_Return, spawn, SHCMD("st tmux")},

// toggle stuff
{MODKEY, XK_b, togglebar, {0}},
{MODKEY | ControlMask, XK_t, togglegaps, {0}},
{MODKEY | ShiftMask, XK_space, togglefloating, {0}},
{MODKEY, XK_f, togglefullscr, {0}},

{MODKEY | ControlMask, XK_w, tabmode, {-1}},
{MODKEY, XK_j, focusstack, {.i = +1}},
{MODKEY, XK_k, focusstack, {.i = -1}},
{MODKEY, XK_i, incnmaster, {.i = +1}},
{MODKEY, XK_d, incnmaster, {.i = -1}},

// shift view
{MODKEY, XK_Left, shiftview, {.i = -1}},
{MODKEY, XK_Right, shiftview, {.i = +1}},

// change m,cfact sizes
{MODKEY, XK_h, setmfact, {.f = -0.05}},
{MODKEY, XK_l, setmfact, {.f = +0.05}},
{MODKEY | ShiftMask, XK_h, setcfact, {.f = +0.25}},
{MODKEY | ShiftMask, XK_l, setcfact, {.f = -0.25}},
{MODKEY | ShiftMask, XK_o, setcfact, {.f = 0.00}},

{MODKEY | ShiftMask, XK_j, movestack, {.i = +1}},
{MODKEY | ShiftMask, XK_k, movestack, {.i = -1}},
{MODKEY | ShiftMask, XK_Return, zoom, {0}},
{MODKEY, XK_Tab, view, {0}},

// overall gaps
{MODKEY | ControlMask, XK_i, incrgaps, {.i = +1}},
{MODKEY | ControlMask, XK_d, incrgaps, {.i = -1}},

// inner gaps
{MODKEY | ShiftMask, XK_i, incrigaps, {.i = +1}},
{MODKEY | ControlMask | ShiftMask, XK_i, incrigaps, {.i = -1}},

// outer gaps
{MODKEY | ControlMask, XK_o, incrogaps, {.i = +1}},
{MODKEY | ControlMask | ShiftMask, XK_o, incrogaps, {.i = -1}},

// inner+outer hori, vert gaps
{MODKEY | ControlMask, XK_6, incrihgaps, {.i = +1}},
{MODKEY | ControlMask | ShiftMask, XK_6, incrihgaps, {.i = -1}},
{MODKEY | ControlMask, XK_7, incrivgaps, {.i = +1}},
{MODKEY | ControlMask | ShiftMask, XK_7, incrivgaps, {.i = -1}},
{MODKEY | ControlMask, XK_8, incrohgaps, {.i = +1}},
{MODKEY | ControlMask | ShiftMask, XK_8, incrohgaps, {.i = -1}},
{MODKEY | ControlMask, XK_9, incrovgaps, {.i = +1}},
{MODKEY | ControlMask | ShiftMask, XK_9, incrovgaps, {.i = -1}},

{MODKEY | ControlMask | ShiftMask, XK_d, defaultgaps, {0}},

// layout
{MODKEY, XK_t, setlayout, {.v = &layouts[0]}},
{MODKEY | ShiftMask, XK_f, setlayout, {.v = &layouts[1]}},
{MODKEY, XK_m, setlayout, {.v = &layouts[2]}},
{MODKEY | ControlMask, XK_g, setlayout, {.v = &layouts[10]}},
{MODKEY | ControlMask | ShiftMask, XK_t, setlayout, {.v = &layouts[13]}},
{MODKEY, XK_space, setlayout, {0}},
{MODKEY | ControlMask, XK_comma, cyclelayout, {.i = -1}},
{MODKEY | ControlMask, XK_period, cyclelayout, {.i = +1}},
{MODKEY, XK_0, view, {.ui = ~0}},
{MODKEY | ShiftMask, XK_0, tag, {.ui = ~0}},
{MODKEY, XK_comma, focusmon, {.i = -1}},
{MODKEY, XK_period, focusmon, {.i = +1}},
{MODKEY | ShiftMask, XK_comma, tagmon, {.i = -1}},
{MODKEY | ShiftMask, XK_period, tagmon, {.i = +1}},

// change border size
{MODKEY | ShiftMask, XK_minus, setborderpx, {.i = -1}},
{MODKEY | ShiftMask, XK_p, setborderpx, {.i = +1}},
{MODKEY | ShiftMask, XK_w, setborderpx, {.i = default_border}},

// kill dwm
{MODKEY | ControlMask, XK_q, spawn, SHCMD("killall bar.sh dwm")},

// kill window
{MODKEY, XK_q, killclient, {0}},

// restart
{MODKEY | ShiftMask, XK_r, restart, {0}},

// hide & restore windows
{MODKEY, XK_e, hidewin, {0}},
{MODKEY | ShiftMask, XK_e, restorewin, {0}},

TAGKEYS(XK_1, 0) TAGKEYS(XK_2, 1) TAGKEYS(XK_3, 2) TAGKEYS(XK_4, 3)
TAGKEYS(XK_5, 4) TAGKEYS(XK_6, 5) TAGKEYS(XK_7, 6) TAGKEYS(XK_8, 7)
TAGKEYS(XK_9, 8)

// span background change
{MODKEY | ControlMask, XK_p, spawn, SHCMD("wal")},
// suspend the machine
{MODKEY | ControlMask, XK_l, spawn, SHCMD("systemctl suspend")},
// restart the machine
{MODKEY | ControlMask, XK_r, spawn, SHCMD("reboot")},
// shutdown the machine
{MODKEY | ControlMask, XK_s, spawn, SHCMD("shutdown now")},

// span extended monitor display
/* span left monitor display */
{MODKEY | Mod1Mask, XK_Left, spawn,
SHCMD("xrandr --output HDMI-0 --auto --left-of eDP-1-1")},
/* span right monitor display */
{MODKEY | Mod1Mask, XK_Right, spawn,
SHCMD("xrandr --output HDMI-0 --auto --right-of eDP-1-1")},

// span bubbly display
/* span the chat display */
{MODKEY | ControlMask, XK_c, spawn, SHCMD("bubbly chat")},
/* span the keystrokes display */
{MODKEY | ControlMask, XK_k, spawn, SHCMD("bubbly keystrokes")},
// Open flatpak's smile
// {MODKEY | ControlMask, XK_., spawn, SHCMD("flatpak run it.mijorus.smile")},
// Toggle menu bar
// {MODKEY | ControlMask, XK_m, togglebar, {0}},
{MODKEY | Mod1Mask, XK_m, spawn,
SHCMD("~/.config/chadwm/scripts/toggle_menu.sh")},
};

/* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
* ClkClientWin, or ClkRootWin */
static const Button buttons[] = {
/* click event mask button function argument */
{ClkLtSymbol, 0, Button1, setlayout, {0}},
{ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]}},
{ClkWinTitle, 0, Button2, zoom, {0}},
{ClkStatusText, 0, Button2, spawn, SHCMD("st")},

/* Keep movemouse? */
/* { ClkClientWin, MODKEY, Button1, movemouse, {0} },
*/

/* placemouse options, choose which feels more natural:
* 0 - tiled position is relative to mouse cursor
* 1 - tiled position is relative to window center
* 2 - mouse pointer warps to window center
*
* The moveorplace uses movemouse or placemouse depending on the floating
* state of the selected client. Set up individual keybindings for the two
* if you want to control these separately (i.e. to retain the feature to
* move a tiled window into a floating position).
*/
{ClkClientWin, MODKEY, Button1, moveorplace, {.i = 0}},
{ClkClientWin, MODKEY, Button2, togglefloating, {0}},
{ClkClientWin, MODKEY, Button3, resizemouse, {0}},
{ClkClientWin, ControlMask, Button1, dragmfact, {0}},
{ClkClientWin, ControlMask, Button3, dragcfact, {0}},
{ClkTagBar, 0, Button1, view, {0}},
{ClkTagBar, 0, Button3, toggleview, {0}},
{ClkTagBar, MODKEY, Button1, tag, {0}},
{ClkTagBar, MODKEY, Button3, toggletag, {0}},
{ClkTabBar, 0, Button1, focuswin, {0}},
{ClkTabBar, 0, Button1, focuswin, {0}},
{ClkTabPrev, 0, Button1, movestack, {.i = -1}},
{ClkTabNext, 0, Button1, movestack, {.i = +1}},
{ClkTabClose, 0, Button1, killclient, {0}},
};
Loading

0 comments on commit 7893063

Please sign in to comment.