diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | config.def.h | 106 | ||||
| l--------- | config.h | 1 | ||||
| -rw-r--r-- | dwm.1 | 3 | ||||
| -rw-r--r-- | dwm.c | 8 | 
5 files changed, 106 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..095e840 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.o +dwm diff --git a/config.def.h b/config.def.h index 9efa774..178b46e 100644 --- a/config.def.h +++ b/config.def.h @@ -1,21 +1,29 @@  /* 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 snap      = 32;       /* snap pixel */  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 *fonts[]          = { "monospace:size=11" }; +static const char dmenufont[]       = "monospace:size=11"; + +/* + * Base16 dwm template by Daniel Mulford + * Tomorrow Night scheme by Chris Kempson (http://chriskempson.com) + */ +static const char col_base00[]      = "#1d1f21"; +static const char col_base01[]      = "#282a2e"; +static const char col_base02[]      = "#373b41"; +static const char col_base04[]      = "#b4b7b4"; +static const char col_base0C[]      = "#8abeb7"; +static const char col_base0D[]      = "#81a2be";  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_base04, col_base01, col_base02 }, +	[SchemeSel]  = { col_base00, col_base0D, col_base0C },  };  /* tagging */ @@ -28,7 +36,7 @@ static const Rule rules[] = {  	 */  	/* class      instance    title       tags mask     isfloating   monitor */  	{ "Gimp",     NULL,       NULL,       0,            1,           -1 }, -	{ "Firefox",  NULL,       NULL,       1 << 8,       0,           -1 }, +//	{ "qBittorrent", NULL,    NULL,       1 << 5,       0,           -1 },  };  /* layout(s) */ @@ -45,7 +53,7 @@ static const Layout layouts[] = {  };  /* key definitions */ -#define MODKEY Mod1Mask +#define MODKEY Mod4Mask  #define TAGKEYS(KEY,TAG) \  	{ MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \  	{ MODKEY|ControlMask,           KEY,      toggleview,     {.ui = 1 << TAG} }, \ @@ -57,8 +65,17 @@ static const Layout layouts[] = {  /* 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[]  = { "st", NULL }; +static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_base01, "-nf", col_base04, "-sb", col_base0D, "-sf", col_base00, NULL }; +static const char *termcmd[]  = { "alacritty", NULL }; +static const char *lower_volume_cmd[] = { "/bin/sh", "-c", "amixer set Master 5%-; kill -RTMIN+1 $(pidof -x sbar)", NULL }; +static const char *mutecmd[] = { "/bin/sh", "-c", "amixer set Master toggle; kill -RTMIN+1 $(pidof -x sbar)", NULL }; +static const char *nextcmd[] = { "playerctl", "next", NULL }; +static const char *playcmd[] = { "playerctl", "play-pause", NULL }; +static const char *prevcmd[] = { "playerctl", "previous", NULL }; +static const char *raise_volume_cmd[] = { "/bin/sh", "-c", "amixer set Master 5%+; kill -RTMIN+1 $(pidof -x sbar)", NULL }; +static const char *bright_up_cmd[] = { "backlight", "-u", NULL }; +static const char *bright_down_cmd[] = { "backlight", "-d", NULL }; +static const char *toggle_audio_capture_cmd[] = { "/bin/sh", "-c", "amixer set Capture toggle; kill -RTMIN $(pidof -x sbar)", NULL };  static const Key keys[] = {  	/* modifier                     key        function        argument */ @@ -79,6 +96,7 @@ static const Key keys[] = {  	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },  	{ MODKEY,                       XK_space,  setlayout,      {0} },  	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} }, +	{ MODKEY|ShiftMask,             XK_f,      togglefullscr,  {0} },  	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },  	{ MODKEY|ShiftMask,             XK_0,      tag,            {.ui = ~0 } },  	{ MODKEY,                       XK_comma,  focusmon,       {.i = -1 } }, @@ -95,6 +113,66 @@ static const Key keys[] = {  	TAGKEYS(                        XK_8,                      7)  	TAGKEYS(                        XK_9,                      8)  	{ MODKEY|ShiftMask,             XK_q,      quit,           {0} }, +	{ MODKEY, XK_F2, spawn, {.v = lower_volume_cmd } }, +	{ MODKEY, XK_F1, spawn, {.v = mutecmd } }, +	{ MODKEY, XK_F6, spawn, {.v = nextcmd } }, +	{ MODKEY, XK_F5, spawn, {.v = playcmd } }, +	{ MODKEY, XK_F4, spawn, {.v = prevcmd } }, +	{ MODKEY, XK_F3, spawn, {.v = raise_volume_cmd } }, +	{ MODKEY, XK_F12, spawn, {.v = bright_up_cmd } }, +	{ MODKEY, XK_F11, spawn, {.v = bright_down_cmd } }, +	{ MODKEY|ShiftMask, XK_F1, spawn, {.v = toggle_audio_capture_cmd } }, +	{ 0, XF86XK_AudioLowerVolume, spawn, {.v = lower_volume_cmd } }, +	{ 0, XF86XK_AudioMute, spawn, {.v = mutecmd } }, +	{ 0, XF86XK_AudioNext, spawn, {.v = nextcmd } }, +	{ 0, XF86XK_AudioPlay, spawn, {.v = playcmd } }, +	{ 0, XF86XK_AudioPrev, spawn, {.v = prevcmd } }, +	{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = raise_volume_cmd } }, +	{ 0, XF86XK_MonBrightnessUp, spawn, {.v = bright_up_cmd } }, +	{ 0, XF86XK_MonBrightnessDown, spawn, {.v = bright_down_cmd } }, +	// mod-shift-prtsc and mod-ctrl-prtsc does not work well, maybe because of sysrq? but mod-prtsc works well tho +	{ 0, XK_Print, spawn, SHCMD("ffmpeg -f x11grab -i \"$DISPLAY\" -vframes 1 \"$XDG_PICTURES_DIR/screenshots/$(time-uuid).jxl\" && notify-send 'Screenshot Finished'") }, +	{ MODKEY, XF86XK_AudioMute, spawn, {.v = toggle_audio_capture_cmd } }, +	// steal GPL-2.0-or-later code from https://git.zx2c4.com/password-store/tree/contrib/dmenu/passmenu#n34 +	// I use `{ IFS= read -r p; printf '%s\r' \"$p\";}` because it is much faster than  `| head -n1` +	{ MODKEY, XK_a, spawn, SHCMD("pass master | { IFS= read -r p; printf '%s\r' \"$p\";} | xdotool type --clearmodifiers --file -") }, +	{ MODKEY, XK_e, spawn, SHCMD("firefox --search \"$(xsel -op)\"") }, +	{ MODKEY, XK_g, spawn, SHCMD("xrectsel '%w %h %x %y' | xargs sh -c 'ffmpeg -f x11grab -s \"$1x$2\" -i \"$DISPLAY+$3,$4\" -vframes 1 \"$XDG_PICTURES_DIR/screenshots/$(time-uuid).jxl\"' shell && notify-send 'Screenshot Finished'") }, +	{ MODKEY, XK_n, spawn, SHCMD("dunstctl close") }, +	{ MODKEY, XK_o, spawn, SHCMD("pme -u") }, +	// https://unix.stackexchange.com/a/568679/459013 +	// https://stackoverflow.com/q/8696751/9008720 +	// alternative: `sed 's/./& /g'` or sed 's/./& /g;s/ $//'` +	// my benchmark shows in larger dataset, awk way is faster +	{ MODKEY, XK_r, spawn, SHCMD("xsel -ob | awk '{$1=$1}1' FS= | xsel -ib") }, +	// Use "$(xsel -op)" instead of "xsel -op | sdcv" (with sh -c?) because: the latter won't quit if found items similar and require user input. Not sure why. +	// use env inside, to fix a bug: alacritty created by `alacritty msg create-window` will quit immediately if result is less than one page. +	{ MODKEY, XK_s, spawn, SHCMD("alacritty -e env LESS=\"$LESS-+F\" sdcv --color \"$(xsel -op)\"") }, +	// firefox Userjs toggle RFP +	{ MODKEY, XK_u, spawn, SHCMD("ujs -r") }, +	{ MODKEY, XK_v, spawn, SHCMD("vpn \"$(printf 'mydefault\naa\nca\nia\nstudio\n' | dmenu -p 'vpn')\"") }, +	{ MODKEY, XK_w, spawn, SHCMD("\"$BROWSER\"") }, +	{ MODKEY, XK_x, spawn, SHCMD("sleep 0.3; xcross") }, +	{ MODKEY, XK_y, spawn, SHCMD("mpvy -s") }, +	{ MODKEY, XK_z, spawn, SHCMD("0 \"$(xsel -op)\"") }, +	{ MODKEY|ControlMask, XK_a, spawn, SHCMD("pass master3 | { IFS= read -r p; printf '%s\r' \"$p\";} | xdotool type --clearmodifiers --file -") }, +	{ MODKEY|ControlMask, XK_g, spawn, SHCMD("reco -f") }, +	{ MODKEY|ControlMask, XK_o, spawn, SHCMD("pme -o") }, +	// use -u url so tsp can show urls for each tasks +	{ MODKEY|ControlMask, XK_y, spawn, SHCMD("tsp mpvy -A -u \"$(xsel -ob)\"") }, +	{ MODKEY|ShiftMask, XK_a, spawn, SHCMD("pass master2 | { IFS= read -r p; printf '%s\r' \"$p\";} | xdotool type --clearmodifiers --file -") }, +	{ MODKEY|ShiftMask, XK_e, spawn, SHCMD("firefox --search \"$(xsel -ob)\"") }, +	{ MODKEY|ShiftMask, XK_g, spawn, SHCMD("reco") }, +	{ MODKEY|ShiftMask, XK_n, spawn, SHCMD("alarm 12 'Boiling Water!'") }, +	{ MODKEY|ShiftMask, XK_o, spawn, SHCMD("pme") }, +	{ MODKEY|ShiftMask, XK_r, spawn, SHCMD("xsel -ob | rev | xsel -ib") }, +	{ MODKEY|ShiftMask, XK_s, spawn, SHCMD("alacritty -e env LESS=\"$LESS-+F\" sdcv --color \"$(xsel -ob)\"") }, +	// firefox Userjs toggle webgl +	{ MODKEY|ShiftMask, XK_u, spawn, SHCMD("ujs -w") }, +	{ MODKEY|ShiftMask, XK_w, spawn, SHCMD("\"$BROWSER\" \"youtu.be/$(xsel -op)\"") }, +	{ MODKEY|ShiftMask, XK_y, spawn, SHCMD("mpvy -a") }, +	{ MODKEY|ShiftMask, XK_z, spawn, SHCMD("0 \"$(xsel -ob)\"") }, +	{ MODKEY|ControlMask|ShiftMask, XK_y, spawn, SHCMD("tsp mpvy -Ac -u \"$(xsel -ob)\"") },  };  /* button definitions */ diff --git a/config.h b/config.h new file mode 120000 index 0000000..c6d6219 --- /dev/null +++ b/config.h @@ -0,0 +1 @@ +config.def.h
\ No newline at end of file @@ -116,6 +116,9 @@ Zooms/cycles focused window to/from master area (tiled layouts only).  .B Mod1\-Shift\-c  Close focused window.  .TP +.B Mod1\-Shift\-f +Toggle fullscreen for focused window. +.TP  .B Mod1\-Shift\-space  Toggle focused window between tiled and floating state.  .TP @@ -210,6 +210,7 @@ static void tagmon(const Arg *arg);  static void tile(Monitor *m);  static void togglebar(const Arg *arg);  static void togglefloating(const Arg *arg); +static void togglefullscr(const Arg *arg);  static void toggletag(const Arg *arg);  static void toggleview(const Arg *arg);  static void unfocus(Client *c, int setfocus); @@ -1735,6 +1736,13 @@ togglefloating(const Arg *arg)  }  void +togglefullscr(const Arg *arg) +{ +  if(selmon->sel) +    setfullscreen(selmon->sel, !selmon->sel->isfullscreen); +} + +void  toggletag(const Arg *arg)  {  	unsigned int newtags;  | 
