From adea9b916ef174994f90dd57aa31a1d403e272fa Mon Sep 17 00:00:00 2001 From: faulty Date: Mon, 20 Feb 2023 01:26:02 +0100 Subject: [PATCH] feat: dwm --- files/dwm/config.h | 128 +++++++++++++++++++++ files/dwm/dwm-start.sh | 31 +++++ files/dwm/dwm.desktop | 6 + files/home/.config/alacritty/alacritty.yml | 2 + scripts/30-dwm.sh | 34 ++++++ 5 files changed, 201 insertions(+) create mode 100644 files/dwm/config.h create mode 100755 files/dwm/dwm-start.sh create mode 100644 files/dwm/dwm.desktop create mode 100644 scripts/30-dwm.sh diff --git a/files/dwm/config.h b/files/dwm/config.h new file mode 100644 index 0000000..996e250 --- /dev/null +++ b/files/dwm/config.h @@ -0,0 +1,128 @@ +/* See LICENSE file for copyright and license details. */ + +/* appearance */ +static const unsigned int borderpx = 1; /* border pixel of windows */ +static const unsigned int snap = 32; /* snap pixel */ +static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ +static const unsigned int systrayonleft = 0; /* 0: systray in the right corner, >0: systray on left of status text */ +static const unsigned int systrayspacing = 2; /* systray spacing */ +static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ +static const int showsystray = 1; /* 0 means no systray */ +static const int showbar = 1; /* 0 means no bar */ +static const int topbar = 1; /* 0 means bottom bar */ +static const char *fonts[] = { "monospace:size=10" }; +static const char dmenufont[] = "monospace:size=10"; +static const char col_gray1[] = "#222222"; +static const char col_gray2[] = "#444444"; +static const char col_gray3[] = "#bbbbbb"; +static const char col_gray4[] = "#eeeeee"; +static const char col_cyan[] = "#005577"; +static const char *colors[][3] = { + /* fg bg border */ + [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, + [SchemeSel] = { col_gray4, col_cyan, col_cyan }, +}; + +/* tagging */ +static const char *tags[] = { "main", "term", "www", "chat", "5", "6", "7", "8", "9", }; + +static const Rule rules[] = { + /* class instance title tags mask isfloating monitor */ + { "Gimp", NULL, NULL, 0, True, -1 }, + { "Firefox", NULL, NULL, 0, False, -1 }, + { "Thunderbird", NULL, NULL, 2, False, -1 }, + { "stalonetray", NULL, NULL, 1, False, -1 }, + { "chrome", NULL, NULL, 4, False, -1 }, +}; + +/* layout(s) */ +static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const Bool resizehints = True; /* True means respect size hints in tiled resizals */ +static const int nmaster = 1; /* number of clients in master area */ +static const int lockfullscreen = 1; /* 1 will force focus on the fullscreen window */ + +static const Layout layouts[] = { + /* symbol arrange function */ + { "[]=", tile }, /* first entry is default */ + { "><>", NULL }, /* no layout function means floating behavior */ + { "[M]", monocle }, +}; + +/* 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 char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; + +static const char *termcmd[] = { "alacritty", NULL }; +static const char *locksaver[] = { "i3lock", "-c", "#000000", NULL }; + +static const char *volup[] = { "amixer", "set", "Master", "5%+", NULL }; +static const char *voldown[] = { "amixer", "set", "Master", "5%-", NULL }; + +static const char *dwmdie[] = { "killall", "dwm-start", NULL }; +static Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_Return, spawn, {.v = termcmd } }, + { MODKEY|ShiftMask, XK_d, spawn, {.v = dmenucmd } }, + { MODKEY|ShiftMask, XK_e, spawn, {.v = dwmdie } }, + { MODKEY, XK_l, spawn, {.v = locksaver } }, + { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY|Mod1Mask, XK_h, incnmaster, {.i = +1} }, + { MODKEY|Mod1Mask, XK_u, incnmaster, {.i = -1} }, + { MODKEY|ShiftMask, XK_Return, zoom, {0} }, + { MODKEY, XK_Tab, view, {0} }, + { MODKEY|ShiftMask, XK_c, killclient, {0} }, + { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, + { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { 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 } }, + { MODKEY, XK_Up, spawn, {.v = volup } }, + { MODKEY, XK_Down, spawn, {.v = voldown } }, + 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) + { MODKEY|ShiftMask|Mod1Mask, XK_q, quit, {0} }, +}; + +/* button definitions */ +/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +static 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, {.v = termcmd } }, + { ClkClientWin, MODKEY, Button1, movemouse, {0} }, + { ClkClientWin, MODKEY, Button2, togglefloating, {0} }, + { ClkClientWin, MODKEY, Button3, resizemouse, {0} }, + { ClkTagBar, 0, Button1, view, {0} }, + { ClkTagBar, 0, Button3, toggleview, {0} }, + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, +}; + diff --git a/files/dwm/dwm-start.sh b/files/dwm/dwm-start.sh new file mode 100755 index 0000000..40bf68f --- /dev/null +++ b/files/dwm/dwm-start.sh @@ -0,0 +1,31 @@ +#!/bin/sh +gnome-screensaver & + +xsetroot -solid black + +#while loop to update statusbar with some goodies +while true; do + #memfreak to get it in MB + memfreak2=$(grep MemFree /proc/meminfo | awk '{ print $2 }') + memfreak=$(($memfreak2 / 1024)) + #time + CLK=$(date +'%a %b %d %R:%S %Z') + #volume + VOL=$(amixer get Master | tail -1 | awk '{ print $5 }' | tr -d '[]') + #loadavg + AVG=$(cat /proc/loadavg | cut -d ' ' -f -3) + #network stats in Bytes + NW=$(dstat -n --nocolor 1 1 | tail -1 | awk '{ print $1, $2}') + battper=$(cat /sys/class/power_supply/BAT0/capacity) + #this one is not so good, increases a delay of 1-2s of the updating. + #put it in the xsetrootname plz (tip of the day, do not put | as first char after " + xsetroot -name "$AVG | $memfreak MB | Bat: $battper% | Vol: $VOL | $CLK | " + sleep 1 +done & + + +nm-applet & +mate-volume-control-status-icon & +feh -z -Z --bg-scale /home/didier/Pictures/background.png + +exec dwm >/dev/null diff --git a/files/dwm/dwm.desktop b/files/dwm/dwm.desktop new file mode 100644 index 0000000..2f8e70f --- /dev/null +++ b/files/dwm/dwm.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=dwm +Comment=This session starts dwm +Exec=/usr/local/bin/dwm-start +Type=Application \ No newline at end of file diff --git a/files/home/.config/alacritty/alacritty.yml b/files/home/.config/alacritty/alacritty.yml index 3bc0096..882e5c9 100644 --- a/files/home/.config/alacritty/alacritty.yml +++ b/files/home/.config/alacritty/alacritty.yml @@ -2,6 +2,8 @@ bell: animation: 'Ease' duration: 50 color: '#555555' +font: + size: 7.0 cursor: style: shape: 'Block' diff --git a/scripts/30-dwm.sh b/scripts/30-dwm.sh new file mode 100644 index 0000000..6813bc5 --- /dev/null +++ b/scripts/30-dwm.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +# This file configures builds and installs DWM. + +# install dependencies +$SUDO $PM $PM_INSTALL $PM_NOCONFIRM \ + feh \ + network-manager-applet \ + alsa-utils \ + dstat \ + curl + +# clone +[ -d /tmp/dotfiles-dwm ] || git clone https://git.suckless.org/dwm /tmp/dotfiles-dwm + +# config +cp ./files/dwm/config.h /tmp/dotfiles-dwm/config.h + +# build, patch and install +pushd /tmp/dotfiles-dwm + +# patches +curl https://dwm.suckless.org/patches/systray/dwm-systray-6.4.diff -o /tmp/dwm-systray.diff +git apply -3 /tmp/dwm-systray.diff + +$SUDO make install +popd + +# start script +chmod +x ./files/dwm/dwm-start.sh +$SUDO cp ./files/dwm/dwm-start.sh /usr/local/bin/dwm-start + +# DM entry +$SUDO cp ./files/dwm/dwm.desktop /usr/share/xsessions/dwm.desktop \ No newline at end of file