t* dwm + patches URI git clone git://git.codevoid.de/dwm-sdk DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit 74f4a5968e3410a9017b98ceeabbaa74a3c9ce80 DIR parent 330633b5a3c5c70618bc3c98aab68bcf4821bb6e URI Author: Stefan Hagen <sh+git[at]codevoid[dot]de> Date: Fri, 25 May 2018 10:51:00 +0200 Style + self_restart patch Diffstat: M config.def.h | 4 +++- M config.h | 37 ++++++++++++++++++++++++++----- A patches/dwm-r1615-selfrestart.diff | 101 +++++++++++++++++++++++++++++++ A selfrestart.c | 65 +++++++++++++++++++++++++++++++ 4 files changed, 200 insertions(+), 7 deletions(-) --- DIR diff --git a/config.def.h b/config.def.h t@@ -67,6 +67,8 @@ static const char *termcmd[] = { "st", NULL }; static const char scratchpadname[] = "scratchpad"; static const char *scratchpadcmd[] = { "st", "-t", scratchpadname, "-g", "120x34", NULL }; +#include "selfrestart.c" + static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_p, spawn, {.v = dmenucmd } }, t@@ -104,6 +106,7 @@ static Key keys[] = { TAGKEYS( XK_7, 6) TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) + { MODKEY|ShiftMask, XK_r, self_restart, {0} }, { MODKEY|ShiftMask, XK_q, quit, {0} }, }; t@@ -123,4 +126,3 @@ static Button buttons[] = { { ClkTagBar, MODKEY, Button1, tag, {0} }, { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; - DIR diff --git a/config.h b/config.h t@@ -9,21 +9,33 @@ static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display 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[] = { "Droid Sans Mono for Powerline:size=11" }; static const char dmenufont[] = "Droid Sans Mono for Powerline:size=11"; + +static const char col_vdark[] = "#1c1c1c"; +static const char col_dark[] = "#333333"; +static const char col_norm[] = "#666666"; +static const char col_full[] = "#eeeeee"; + 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 }, + /* fg bg border */ + [SchemeNorm] = { col_norm, col_vdark, col_dark }, + [SchemeSel] = { col_full, col_vdark, col_norm }, }; + /* tagging */ -static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +//static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +static const char *tags[] = { "One", "Two", "Three", "Four", "Five" }; static const Rule rules[] = { /* xprop(1): t@@ -36,7 +48,7 @@ static const Rule rules[] = { }; /* layout(s) */ -static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */ +static const float mfact = 0.75; /* 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 */ t@@ -70,6 +82,8 @@ static const char *passmenucmd[] = { ".dwm/passmenu", "-m", dmenumon, "-fn", d static const char *volumeupcmd[] = { ".dwm/mixer", "+2", NULL }; static const char *volumedowncmd[] = { ".dwm/mixer", "-2", NULL }; +#include "selfrestart.c" + static Key keys[] = { /* modifier key function argument */ // application launcher t@@ -137,7 +151,18 @@ static Key keys[] = { TAGKEYS( XK_7, 6) TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) - { MODKEY|ShiftMask, XK_End, quit, {0} }, + { MODKEY|ShiftMask, XK_End, quit, {0} }, + { MODKEY|ShiftMask, XK_Home, self_restart, {0} }, + +// /* Media keys */ +// { 0, XF86XK_AudioRaiseVolume, spawn, {.v = volumeupcmd } }, +// { 0, XF86XK_AudioLowerVolume, spawn, {.v = volumedowncmd } }, +// { 0, XF86XK_AudioMute, spawn, {.v = volmute } }, +// { 0, XF86XK_AudioPlay, spawn, {.v = audioplay } }, +// { 0, XF86XK_AudioPrev, spawn, {.v = audioback } }, +// { 0, XF86XK_AudioNext, spawn, {.v = audionext } }, +// { 0, XF86XK_MonBrightnessUp, spawn, {.v = backlightup } }, +// { 0, XF86XK_MonBrightnessDown, spawn, {.v = backlightdown } } }; /* button definitions */ DIR diff --git a/patches/dwm-r1615-selfrestart.diff b/patches/dwm-r1615-selfrestart.diff t@@ -0,0 +1,101 @@ +# HG changeset patch +# User Barbu Paul - Gheorghe <barbu.paul.gheorghe@gmail.com> +# Date 1354650884 -7200 +# Node ID 6c472a21a5887c5295a331c48c4da188ec2c8413 +# Parent aaab44133a6830c9a00263731d098c01cc1d6fb5 +selfrestart now magically locates the current dwm (no need to hardcode a path) + +diff -r aaab44133a68 -r 6c472a21a588 config.def.h +--- a/config.def.h Tue Dec 04 21:54:44 2012 +0200 ++++ b/config.def.h Tue Dec 04 21:54:44 2012 +0200 +@@ -54,6 +54,8 @@ + static const char *termcmd[] = { "urxvtc", NULL }; + static const char *filemancmd[] = { "thunar", NULL }; + ++#include "selfrestart.c" ++ + static Key keys[] = { + /* modifier key function argument */ + { MODKEY, XK_r, spawn, {.v = dmenucmd } }, +@@ -89,6 +91,7 @@ + TAGKEYS( XK_7, 6) + TAGKEYS( XK_8, 7) + TAGKEYS( XK_9, 8) ++ { MODKEY|ShiftMask, XK_r, self_restart, {0} }, + { MODKEY|ShiftMask, XK_q, quit, {0} }, + }; + +@@ -108,4 +111,3 @@ + { ClkTagBar, MODKEY, Button1, tag, {0} }, + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, + }; +- +diff -r aaab44133a68 -r 6c472a21a588 selfrestart.c +--- /dev/null Thu Jan 01 00:00:00 1970 +0000 ++++ b/selfrestart.c Tue Dec 04 21:54:44 2012 +0200 +@@ -0,0 +1,65 @@ ++#include <unistd.h> ++#include <sys/types.h> ++#include <sys/stat.h> ++#include <stdio.h> ++#include <stdlib.h> ++ ++/** ++ * Magically finds the current's executable path ++ * ++ * I'm doing the do{}while(); trick because Linux (what I'm running) is not ++ * POSIX compilant and so lstat() cannot be trusted on /proc entries ++ * ++ * @return char* the path of the current executable ++ */ ++char *get_dwm_path(){ ++ struct stat s; ++ int r, length, rate = 42; ++ char *path = NULL; ++ ++ if(lstat("/proc/self/exe", &s) == -1){ ++ perror("lstat:"); ++ return NULL; ++ } ++ ++ length = s.st_size + 1 - rate; ++ ++ do{ ++ length+=rate; ++ ++ free(path); ++ path = malloc(sizeof(char) * length); ++ ++ if(path == NULL){ ++ perror("malloc:"); ++ return NULL; ++ } ++ ++ r = readlink("/proc/self/exe", path, length); ++ ++ if(r == -1){ ++ perror("readlink:"); ++ return NULL; ++ } ++ }while(r >= length); ++ ++ path[r] = '\0'; ++ ++ return path; ++} ++ ++/** ++ * self-restart ++ * ++ * Initially inspired by: Yu-Jie Lin ++ * https://sites.google.com/site/yjlnotes/notes/dwm ++ */ ++void self_restart(const Arg *arg) { ++ char *const argv[] = {get_dwm_path(), NULL}; ++ ++ if(argv[0] == NULL){ ++ return; ++ } ++ ++ execv(argv[0], argv); ++} DIR diff --git a/selfrestart.c b/selfrestart.c t@@ -0,0 +1,65 @@ +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <stdio.h> +#include <stdlib.h> + +/** + * Magically finds the current's executable path + * + * I'm doing the do{}while(); trick because Linux (what I'm running) is not + * POSIX compilant and so lstat() cannot be trusted on /proc entries + * + * @return char* the path of the current executable + */ +char *get_dwm_path(){ + struct stat s; + int r, length, rate = 42; + char *path = NULL; + + if(lstat("/proc/self/exe", &s) == -1){ + perror("lstat:"); + return NULL; + } + + length = s.st_size + 1 - rate; + + do{ + length+=rate; + + free(path); + path = malloc(sizeof(char) * length); + + if(path == NULL){ + perror("malloc:"); + return NULL; + } + + r = readlink("/proc/self/exe", path, length); + + if(r == -1){ + perror("readlink:"); + return NULL; + } + }while(r >= length); + + path[r] = '\0'; + + return path; +} + +/** + * self-restart + * + * Initially inspired by: Yu-Jie Lin + * https://sites.google.com/site/yjlnotes/notes/dwm + */ +void self_restart(const Arg *arg) { + char *const argv[] = {get_dwm_path(), NULL}; + + if(argv[0] == NULL){ + return; + } + + execv(argv[0], argv); +}