diff --git a/.config/mutt/accounts/2-yigit@yigitcolakoglu.com.muttrc b/.config/mutt/accounts/2-yigit@yigitcolakoglu.com.muttrc index 03e697d1..b40113e4 100644 --- a/.config/mutt/accounts/2-yigit@yigitcolakoglu.com.muttrc +++ b/.config/mutt/accounts/2-yigit@yigitcolakoglu.com.muttrc @@ -1,6 +1,6 @@ # vim: filetype=neomuttrc # muttrc file for account yigit@yigitcolakoglu.com -set realname = "yigit" +set realname = "Yigit Colakoglu" set from = "yigit@yigitcolakoglu.com" set sendmail = "msmtp -a yigit@yigitcolakoglu.com" alias me yigit diff --git a/.config/vim/plugin/plugins.vim b/.config/vim/plugin/plugins.vim index b37db88a..dfc00eee 100644 --- a/.config/vim/plugin/plugins.vim +++ b/.config/vim/plugin/plugins.vim @@ -25,6 +25,7 @@ Plug 'jlanzarotta/bufexplorer' Plug 'jeffkreeftmeijer/vim-numbertoggle' Plug 'rhysd/vim-grammarous' Plug 'chrisbra/NrrwRgn' +Plug 'robertbasic/vim-hugo-helper' "Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } Plug 'sheerun/vim-polyglot' Plug 'M4R7iNP/vim-inky' diff --git a/.local/bin/mpd-notif b/.local/bin/mpd-notif index a847d918..34a7d4c7 100755 --- a/.local/bin/mpd-notif +++ b/.local/bin/mpd-notif @@ -3,4 +3,4 @@ title=$(mpc -f "%title%" 2> /dev/null | head -n 1 | xargs) artist=$(mpc -f "%artist%" 2> /dev/null | head -n 1 | xargs) -notify-send -r 120 -a " $artist" -t 1500 "~ $title ~ " +notify-send -a " $artist" -t 1500 "~ $title ~ " diff --git a/.local/bin/password_manager b/.local/bin/password_manager index cd27e23e..5b9631d0 100755 --- a/.local/bin/password_manager +++ b/.local/bin/password_manager @@ -2,7 +2,7 @@ shopt -s nullglob globstar -typeit=0 +typeit=1 if [[ $1 == "--type" ]]; then typeit=1 shift @@ -24,20 +24,16 @@ case "$action" in echo "$username" | xclip -selection clipboard notify-send -a " Password Manager" "Username copied to clipboard";; Password) - if [[ $typeit -eq 0 ]]; then - pass show -c "$entry" 2>/dev/null - else - pass show "$entry" | { IFS= read -r pass; printf %s "$pass"; } | - xdotool type --clearmodifiers --file - - fi + password=$(pass show "$entry") + echo "$password" | xclip -selection clipboard + echo "$password" | { IFS= read -r pass; printf %s "$pass"; } | + xdotool type --clearmodifiers --file - notify-send -a " Password Manager" "Password copied to clipboard";; TOTP) - if [[ $typeit -eq 0 ]]; then - pass otp -c "$entry" 2>/dev/null - else - pass otp "$entry" | { IFS= read -r pass; printf %s "$pass"; } | - xdotool type --clearmodifiers --file - - fi + otp=$(pass otp "$entry") + echo "$otp" | xclip -selection clipboard + echo "$otp" | { IFS= read -r pass; printf %s "$pass"; } | + xdotool type --clearmodifiers --file - notify-send -a " Password Manager" "TOTP copied to clipboard";; esac diff --git a/.local/src/dwm/Makefile b/.local/src/dwm/Makefile index 77bcbc02..f837f5cf 100644 --- a/.local/src/dwm/Makefile +++ b/.local/src/dwm/Makefile @@ -38,7 +38,7 @@ dist: clean install: all mkdir -p ${DESTDIR}${PREFIX}/bin - cp -f dwm ${DESTDIR}${PREFIX}/bin + cp -f dwm dwmc ${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 diff --git a/.local/src/dwm/config.def.h b/.local/src/dwm/config.def.h index 358c35e8..13a3bfb3 100644 --- a/.local/src/dwm/config.def.h +++ b/.local/src/dwm/config.def.h @@ -231,3 +231,73 @@ static Button buttons[] = { { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; +void +setlayoutex(const Arg *arg) +{ + setlayout(&((Arg) { .v = &layouts[arg->i] })); +} + +void +viewex(const Arg *arg) +{ + view(&((Arg) { .ui = 1 << arg->ui })); +} + +void +viewall(const Arg *arg) +{ + view(&((Arg){.ui = ~0})); +} + +void +toggleviewex(const Arg *arg) +{ + toggleview(&((Arg) { .ui = 1 << arg->ui })); +} + +void +tagex(const Arg *arg) +{ + tag(&((Arg) { .ui = 1 << arg->ui })); +} + +void +toggletagex(const Arg *arg) +{ + toggletag(&((Arg) { .ui = 1 << arg->ui })); +} + +void +tagall(const Arg *arg) +{ + tag(&((Arg){.ui = ~0})); +} + +/* signal definitions */ +/* signum must be greater than 0 */ +/* trigger signals using `xsetroot -name "fsignal: [ ]"` */ +static Signal signals[] = { + /* signum function */ + { "focusstack", focusstack }, + { "setmfact", setmfact }, + { "togglebar", togglebar }, + { "incnmaster", incnmaster }, + { "togglefloating", togglefloating }, + { "focusmon", focusmon }, + { "tagmon", tagmon }, + { "zoom", zoom }, + { "view", view }, + { "viewall", viewall }, + { "viewex", viewex }, + { "toggleview", view }, + { "toggleviewex", toggleviewex }, + { "tag", tag }, + { "tagall", tagall }, + { "tagex", tagex }, + { "toggletag", tag }, + { "toggletagex", toggletagex }, + { "killclient", killclient }, + { "quit", quit }, + { "setlayout", setlayout }, + { "setlayoutex", setlayoutex }, +}; diff --git a/.local/src/dwm/config.h b/.local/src/dwm/config.h index ba55c36e..c728f95b 100644 --- a/.local/src/dwm/config.h +++ b/.local/src/dwm/config.h @@ -76,3 +76,7 @@ static Button buttons[] = { { ClkTagBar, MODKEY, Button3, toggletag, {0} }, }; +static Signal signals[] = { + /* signum function */ + { "focusstack", focusstack }, +}; diff --git a/.local/src/dwm/dwm.c b/.local/src/dwm/dwm.c index 7669bfee..25bf3cd1 100644 --- a/.local/src/dwm/dwm.c +++ b/.local/src/dwm/dwm.c @@ -118,11 +118,17 @@ typedef struct { const Arg arg; } Key; +typedef struct { + const char * sig; + void (*func)(const Arg *); +} Signal; + typedef struct { const char *symbol; void (*arrange)(Monitor *); } Layout; +typedef struct Pertag Pertag; struct Monitor { char ltsymbol[16]; float mfact; @@ -147,6 +153,7 @@ struct Monitor { Monitor *next; Window barwin; const Layout *lt[2]; + Pertag *pertag; }; typedef struct { @@ -169,6 +176,7 @@ static void arrangemon(Monitor *m); static void attach(Client *c); static void attachaside(Client *c); static void attachstack(Client *c); +static int fake_signal(void); static void buttonpress(XEvent *e); static void checkotherwm(void); static void cleanup(void); @@ -326,6 +334,15 @@ static xcb_connection_t *xcon; #include "keybinds.h" #include "rules.h" +struct Pertag { + unsigned int curtag, prevtag; /* current and previous tag */ + int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */ + float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */ + unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */ + const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */ + int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */ +}; + /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; @@ -555,15 +572,16 @@ buttonpress(XEvent *e) unsigned int xc; int padding = - sp * 3; /* I don't know why 3 works better than two, but it does */ Arg arg = {0}; - Client *c; + Client *c, *sel; Monitor *m; XButtonPressedEvent *ev = &e->xbutton; click = ClkRootWin; /* focus monitor if necessary */ if ((m = wintomon(ev->window)) && m != selmon) { - unfocus(selmon->sel, 1); + sel = selmon->sel; selmon = m; + unfocus(sel, 1); focus(NULL); } if (ev->window == selmon->barwin) { @@ -842,6 +860,7 @@ Monitor * createmon(void) { Monitor *m; + unsigned int i; m = ecalloc(1, sizeof(Monitor)); m->tagset[0] = m->tagset[1] = 1; @@ -856,6 +875,20 @@ createmon(void) m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + m->pertag = ecalloc(1, sizeof(Pertag)); + m->pertag->curtag = m->pertag->prevtag = 1; + + for (i = 0; i <= LENGTH(tags); i++) { + m->pertag->nmasters[i] = m->nmaster; + m->pertag->mfacts[i] = m->mfact; + + m->pertag->ltidxs[i][0] = m->lt[0]; + m->pertag->ltidxs[i][1] = m->lt[1]; + m->pertag->sellts[i] = m->sellt; + + m->pertag->showbars[i] = m->showbar; + } + return m; } @@ -1164,7 +1197,7 @@ floatpos(const Arg *arg) void enternotify(XEvent *e) { - Client *c; + Client *c, *sel; Monitor *m; XCrossingEvent *ev = &e->xcrossing; @@ -1173,8 +1206,9 @@ enternotify(XEvent *e) c = wintoclient(ev->window); m = c ? c->mon : wintomon(ev->window); if (m != selmon) { - unfocus(selmon->sel, 1); + sel = selmon->sel; selmon = m; + unfocus(sel, 1); } else if (!c || c == selmon->sel) return; focus(c); @@ -1229,13 +1263,15 @@ void focusmon(const Arg *arg) { Monitor *m; + Client *sel; if (!mons->next) return; if ((m = dirtomon(arg->i)) == selmon) return; - unfocus(selmon->sel, 0); + sel = selmon->sel; selmon = m; + unfocus(sel, 0); focus(NULL); } @@ -1504,7 +1540,7 @@ grabkeys(void) void incnmaster(const Arg *arg) { - selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0); arrange(selmon); } @@ -1536,6 +1572,49 @@ keypress(XEvent *e) keys[i].func(&(keys[i].arg)); } +int +fake_signal(void) +{ + char fsignal[256]; + char indicator[9] = "fsignal:"; + char str_sig[50]; + char param[16]; + int i, len_str_sig, n, paramn; + size_t len_fsignal, len_indicator = strlen(indicator); + Arg arg; + + // Get root name property + if (gettextprop(root, XA_WM_NAME, fsignal, sizeof(fsignal))) { + len_fsignal = strlen(fsignal); + + // Check if this is indeed a fake signal + if (len_indicator > len_fsignal ? 0 : strncmp(indicator, fsignal, len_indicator) == 0) { + paramn = sscanf(fsignal+len_indicator, "%s%n%s%n", str_sig, &len_str_sig, param, &n); + + if (paramn == 1) arg = (Arg) {0}; + else if (paramn > 2) return 1; + else if (strncmp(param, "i", n - len_str_sig) == 0) + sscanf(fsignal + len_indicator + n, "%i", &(arg.i)); + else if (strncmp(param, "ui", n - len_str_sig) == 0) + sscanf(fsignal + len_indicator + n, "%u", &(arg.ui)); + else if (strncmp(param, "f", n - len_str_sig) == 0) + sscanf(fsignal + len_indicator + n, "%f", &(arg.f)); + else return 1; + + // Check if a signal was found, and if so handle it + for (i = 0; i < LENGTH(signals); i++) + if (strncmp(str_sig, signals[i].sig, len_str_sig) == 0 && signals[i].func) + signals[i].func(&(arg)); + + // A fake signal was sent + return 1; + } + } + + // No fake signal was sent, so proceed with update + return 0; +} + void killclient(const Arg *arg) { @@ -1666,13 +1745,15 @@ motionnotify(XEvent *e) { static Monitor *mon = NULL; Monitor *m; + Client *sel; XMotionEvent *ev = &e->xmotion; if (ev->window != root) return; if ((m = recttomon(ev->x_root, ev->y_root, 1, 1)) != mon && mon) { - unfocus(selmon->sel, 1); + sel = selmon->sel; selmon = m; + unfocus(sel, 1); focus(NULL); } mon = m; @@ -1771,8 +1852,10 @@ propertynotify(XEvent *e) Window trans; XPropertyEvent *ev = &e->xproperty; - if ((ev->window == root) && (ev->atom == XA_WM_NAME)) - updatestatus(); + if ((ev->window == root) && (ev->atom == XA_WM_NAME)) { + if (!fake_signal()) + updatestatus(); + } else if (ev->state == PropertyDelete) return; /* ignore */ else if ((c = wintoclient(ev->window))) { @@ -2101,9 +2184,9 @@ void setlayout(const Arg *arg) { if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) - selmon->sellt ^= 1; + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1; if (arg && arg->v) - selmon->lt[selmon->sellt] = (Layout *)arg->v; + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v; strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); if (selmon->sel) arrange(selmon); @@ -2122,7 +2205,7 @@ setmfact(const Arg *arg) f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; if (f < 0.05 || f > 0.95) return; - selmon->mfact = f; + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f; arrange(selmon); } @@ -2319,7 +2402,7 @@ tagmon(const Arg *arg) void togglebar(const Arg *arg) { - selmon->showbar = !selmon->showbar; + selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar; updatebarpos(selmon); XMoveResizeWindow(dpy, selmon->barwin, selmon->wx + sp, selmon->by + vp, selmon->ww - 2 * sp, bh); arrange(selmon); @@ -2384,9 +2467,33 @@ void toggleview(const Arg *arg) { unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK); + int i; if (newtagset) { selmon->tagset[selmon->seltags] = newtagset; + + if (newtagset == ~0) { + selmon->pertag->prevtag = selmon->pertag->curtag; + selmon->pertag->curtag = 0; + } + + /* test if the user did not select the same tag */ + if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) { + selmon->pertag->prevtag = selmon->pertag->curtag; + for (i = 0; !(newtagset & 1 << i); i++) ; + selmon->pertag->curtag = i + 1; + } + + /* apply settings for this view */ + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; + selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; + + if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) + togglebar(NULL); + focus(NULL); arrange(selmon); } @@ -2397,6 +2504,8 @@ unfocus(Client *c, int setfocus) { if (!c) return; + if (c->isfullscreen && ISVISIBLE(c) && c->mon == selmon) + setfullscreen(c, 0); grabbuttons(c, 0); XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel); if (setfocus) { @@ -2700,11 +2809,37 @@ updatewmhints(Client *c) void view(const Arg *arg) { + int i; + unsigned int tmptag; + if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) return; selmon->seltags ^= 1; /* toggle sel tagset */ - if (arg->ui & TAGMASK) + if (arg->ui & TAGMASK) { selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; + selmon->pertag->prevtag = selmon->pertag->curtag; + + if (arg->ui == ~0) + selmon->pertag->curtag = 0; + else { + for (i = 0; !(arg->ui & 1 << i); i++) ; + selmon->pertag->curtag = i + 1; + } + } else { + tmptag = selmon->pertag->prevtag; + selmon->pertag->prevtag = selmon->pertag->curtag; + selmon->pertag->curtag = tmptag; + } + + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; + selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; + + if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) + togglebar(NULL); + focus(NULL); arrange(selmon); } diff --git a/.local/src/dwm/dwmc b/.local/src/dwm/dwmc new file mode 100755 index 00000000..5ff8dbc4 --- /dev/null +++ b/.local/src/dwm/dwmc @@ -0,0 +1,40 @@ +#!/usr/bin/env sh + +signal() { + xsetroot -name "fsignal:$*" +} + +case $# in +1) + case $1 in + setlayout | view | viewall | togglebar | togglefloating | zoom | killclient | quit) + signal $1 + ;; + *) + echo "Unknown command or missing one argument." + exit 1 + ;; + esac + ;; +2) + case $1 in + view) + signal $1 ui $2 + ;; + viewex | toggleviewex | tagex | toggletagex | setlayoutex | focusstack | incnmaster | focusmon | tagmon) + signal $1 i $2 + ;; + setmfact) + signal $1 f $2 + ;; + *) + echo "Unknown command or one too many arguments." + exit 1 + ;; + esac + ;; +*) + echo "Too many arguments." + exit 1 + ;; +esac diff --git a/.local/src/dwm/keybinds.h b/.local/src/dwm/keybinds.h index 6c6da1ea..ba486988 100644 --- a/.local/src/dwm/keybinds.h +++ b/.local/src/dwm/keybinds.h @@ -37,8 +37,8 @@ static const char *outmenu[] = {"/home/yigit/.local/bin/dmenu-logout", NULL}; static const char *refresh[] = {"/home/yigit/.local/bin/dmenu-refresh", NULL}; static const char *keyboard[] = {"/home/yigit/.local/bin/kbmap_toggle", NULL}; -static const char *screenshot[] = { "scrot", "/tmp/%Y-%m-%d-%s_$wx$h.png", "-e","xclip -selection clipboard -target image/png -i $f; cp $f ~/Pictures/Screenshots;notify-send \"SNAP\" \"$f\"", NULL }; -static const char *windowshot[] = { "scrot", "-u", "/tmp/%Y-%m-%d-%s_$wx$h.png", "-e","xclip -selection clipboard -target image/png -i $f; cp $f ~/Pictures/Screenshots;notify-send \"SNAP\" \"$f\"", NULL }; +static const char *screenshot[] = { "scrot", "/tmp/%Y-%m-%d-%s_$wx$h.png", "-e","xclip -selection clipboard -target image/png -i $f; cp $f ~/Pictures/Screenshots;notify-send -a \"SNAP\" \"$f\"", NULL }; +static const char *windowshot[] = { "scrot", "-u", "/tmp/%Y-%m-%d-%s_$wx$h.png", "-e","xclip -selection clipboard -target image/png -i $f; cp $f ~/Pictures/Screenshots;notify-send -a \"SNAP\" \"$f\"", NULL }; static const char *simcrop[] = {"simcrop","-fc","-sc", "-g", "900x500",NULL}; static const char *notification[] = {"/home/yigit/.local/bin/dunst_toggle.sh", "-t",NULL}; diff --git a/.local/src/dwm/patches/dwm-dwmc-6.2.diff b/.local/src/dwm/patches/dwm-dwmc-6.2.diff new file mode 100644 index 00000000..bf606d59 --- /dev/null +++ b/.local/src/dwm/patches/dwm-dwmc-6.2.diff @@ -0,0 +1,240 @@ +From d94cb6f1a553d19127f44dbdc96e8bb5041956c2 Mon Sep 17 00:00:00 2001 +From: Nihal Jere +Date: Sat, 21 Mar 2020 15:16:49 -0500 +Subject: [PATCH] dwm-client + +--- + Makefile | 2 +- + config.def.h | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++ + dwm.c | 55 +++++++++++++++++++++++++++++++++++++++-- + dwmc | 40 ++++++++++++++++++++++++++++++ + 4 files changed, 164 insertions(+), 3 deletions(-) + create mode 100755 dwmc + +diff --git a/Makefile b/Makefile +index 77bcbc0..f837f5c 100644 +--- a/Makefile ++++ b/Makefile +@@ -38,7 +38,7 @@ dist: clean + + install: all + mkdir -p ${DESTDIR}${PREFIX}/bin +- cp -f dwm ${DESTDIR}${PREFIX}/bin ++ cp -f dwm dwmc ${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 +diff --git a/config.def.h b/config.def.h +index 1c0b587..efbae79 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -113,3 +113,73 @@ static Button buttons[] = { + { ClkTagBar, MODKEY, Button3, toggletag, {0} }, + }; + ++void ++setlayoutex(const Arg *arg) ++{ ++ setlayout(&((Arg) { .v = &layouts[arg->i] })); ++} ++ ++void ++viewex(const Arg *arg) ++{ ++ view(&((Arg) { .ui = 1 << arg->ui })); ++} ++ ++void ++viewall(const Arg *arg) ++{ ++ view(&((Arg){.ui = ~0})); ++} ++ ++void ++toggleviewex(const Arg *arg) ++{ ++ toggleview(&((Arg) { .ui = 1 << arg->ui })); ++} ++ ++void ++tagex(const Arg *arg) ++{ ++ tag(&((Arg) { .ui = 1 << arg->ui })); ++} ++ ++void ++toggletagex(const Arg *arg) ++{ ++ toggletag(&((Arg) { .ui = 1 << arg->ui })); ++} ++ ++void ++tagall(const Arg *arg) ++{ ++ tag(&((Arg){.ui = ~0})); ++} ++ ++/* signal definitions */ ++/* signum must be greater than 0 */ ++/* trigger signals using `xsetroot -name "fsignal: [ ]"` */ ++static Signal signals[] = { ++ /* signum function */ ++ { "focusstack", focusstack }, ++ { "setmfact", setmfact }, ++ { "togglebar", togglebar }, ++ { "incnmaster", incnmaster }, ++ { "togglefloating", togglefloating }, ++ { "focusmon", focusmon }, ++ { "tagmon", tagmon }, ++ { "zoom", zoom }, ++ { "view", view }, ++ { "viewall", viewall }, ++ { "viewex", viewex }, ++ { "toggleview", view }, ++ { "toggleviewex", toggleviewex }, ++ { "tag", tag }, ++ { "tagall", tagall }, ++ { "tagex", tagex }, ++ { "toggletag", tag }, ++ { "toggletagex", toggletagex }, ++ { "killclient", killclient }, ++ { "quit", quit }, ++ { "setlayout", setlayout }, ++ { "setlayoutex", setlayoutex }, ++}; +diff --git a/dwm.c b/dwm.c +index 4465af1..aa53706 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -106,6 +106,11 @@ typedef struct { + const Arg arg; + } Key; + ++typedef struct { ++ const char * sig; ++ void (*func)(const Arg *); ++} Signal; ++ + typedef struct { + const char *symbol; + void (*arrange)(Monitor *); +@@ -148,6 +153,7 @@ static void arrange(Monitor *m); + static void arrangemon(Monitor *m); + static void attach(Client *c); + static void attachstack(Client *c); ++static int fake_signal(void); + static void buttonpress(XEvent *e); + static void checkotherwm(void); + static void cleanup(void); +@@ -998,6 +1004,49 @@ keypress(XEvent *e) + keys[i].func(&(keys[i].arg)); + } + ++int ++fake_signal(void) ++{ ++ char fsignal[256]; ++ char indicator[9] = "fsignal:"; ++ char str_sig[50]; ++ char param[16]; ++ int i, len_str_sig, n, paramn; ++ size_t len_fsignal, len_indicator = strlen(indicator); ++ Arg arg; ++ ++ // Get root name property ++ if (gettextprop(root, XA_WM_NAME, fsignal, sizeof(fsignal))) { ++ len_fsignal = strlen(fsignal); ++ ++ // Check if this is indeed a fake signal ++ if (len_indicator > len_fsignal ? 0 : strncmp(indicator, fsignal, len_indicator) == 0) { ++ paramn = sscanf(fsignal+len_indicator, "%s%n%s%n", str_sig, &len_str_sig, param, &n); ++ ++ if (paramn == 1) arg = (Arg) {0}; ++ else if (paramn > 2) return 1; ++ else if (strncmp(param, "i", n - len_str_sig) == 0) ++ sscanf(fsignal + len_indicator + n, "%i", &(arg.i)); ++ else if (strncmp(param, "ui", n - len_str_sig) == 0) ++ sscanf(fsignal + len_indicator + n, "%u", &(arg.ui)); ++ else if (strncmp(param, "f", n - len_str_sig) == 0) ++ sscanf(fsignal + len_indicator + n, "%f", &(arg.f)); ++ else return 1; ++ ++ // Check if a signal was found, and if so handle it ++ for (i = 0; i < LENGTH(signals); i++) ++ if (strncmp(str_sig, signals[i].sig, len_str_sig) == 0 && signals[i].func) ++ signals[i].func(&(arg)); ++ ++ // A fake signal was sent ++ return 1; ++ } ++ } ++ ++ // No fake signal was sent, so proceed with update ++ return 0; ++} ++ + void + killclient(const Arg *arg) + { +@@ -1215,8 +1264,10 @@ propertynotify(XEvent *e) + Window trans; + XPropertyEvent *ev = &e->xproperty; + +- if ((ev->window == root) && (ev->atom == XA_WM_NAME)) +- updatestatus(); ++ if ((ev->window == root) && (ev->atom == XA_WM_NAME)) { ++ if (!fake_signal()) ++ updatestatus(); ++ } + else if (ev->state == PropertyDelete) + return; /* ignore */ + else if ((c = wintoclient(ev->window))) { +diff --git a/dwmc b/dwmc +new file mode 100755 +index 0000000..5ff8dbc +--- /dev/null ++++ b/dwmc +@@ -0,0 +1,40 @@ ++#!/usr/bin/env sh ++ ++signal() { ++ xsetroot -name "fsignal:$*" ++} ++ ++case $# in ++1) ++ case $1 in ++ setlayout | view | viewall | togglebar | togglefloating | zoom | killclient | quit) ++ signal $1 ++ ;; ++ *) ++ echo "Unknown command or missing one argument." ++ exit 1 ++ ;; ++ esac ++ ;; ++2) ++ case $1 in ++ view) ++ signal $1 ui $2 ++ ;; ++ viewex | toggleviewex | tagex | toggletagex | setlayoutex | focusstack | incnmaster | focusmon | tagmon) ++ signal $1 i $2 ++ ;; ++ setmfact) ++ signal $1 f $2 ++ ;; ++ *) ++ echo "Unknown command or one too many arguments." ++ exit 1 ++ ;; ++ esac ++ ;; ++*) ++ echo "Too many arguments." ++ exit 1 ++ ;; ++esac +-- +2.25.1 + diff --git a/.local/src/dwm/patches/dwm-pertag-20200914-61bb8b2.diff b/.local/src/dwm/patches/dwm-pertag-20200914-61bb8b2.diff new file mode 100644 index 00000000..c8d7fbcb --- /dev/null +++ b/.local/src/dwm/patches/dwm-pertag-20200914-61bb8b2.diff @@ -0,0 +1,177 @@ +diff --git a/dwm.c b/dwm.c +index 664c527..ac8e4ec 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -111,6 +111,7 @@ typedef struct { + void (*arrange)(Monitor *); + } Layout; + ++typedef struct Pertag Pertag; + struct Monitor { + char ltsymbol[16]; + float mfact; +@@ -130,6 +131,7 @@ struct Monitor { + Monitor *next; + Window barwin; + const Layout *lt[2]; ++ Pertag *pertag; + }; + + typedef struct { +@@ -272,6 +274,15 @@ static Window root, wmcheckwin; + /* configuration, allows nested code to access above variables */ + #include "config.h" + ++struct Pertag { ++ unsigned int curtag, prevtag; /* current and previous tag */ ++ int nmasters[LENGTH(tags) + 1]; /* number of windows in master area */ ++ float mfacts[LENGTH(tags) + 1]; /* mfacts per tag */ ++ unsigned int sellts[LENGTH(tags) + 1]; /* selected layouts */ ++ const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */ ++ int showbars[LENGTH(tags) + 1]; /* display bar for the current tag */ ++}; ++ + /* compile-time check if all tags fit into an unsigned int bit array. */ + struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; + +@@ -632,6 +643,7 @@ Monitor * + createmon(void) + { + Monitor *m; ++ unsigned int i; + + m = ecalloc(1, sizeof(Monitor)); + m->tagset[0] = m->tagset[1] = 1; +@@ -642,6 +654,20 @@ createmon(void) + m->lt[0] = &layouts[0]; + m->lt[1] = &layouts[1 % LENGTH(layouts)]; + strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); ++ m->pertag = ecalloc(1, sizeof(Pertag)); ++ m->pertag->curtag = m->pertag->prevtag = 1; ++ ++ for (i = 0; i <= LENGTH(tags); i++) { ++ m->pertag->nmasters[i] = m->nmaster; ++ m->pertag->mfacts[i] = m->mfact; ++ ++ m->pertag->ltidxs[i][0] = m->lt[0]; ++ m->pertag->ltidxs[i][1] = m->lt[1]; ++ m->pertag->sellts[i] = m->sellt; ++ ++ m->pertag->showbars[i] = m->showbar; ++ } ++ + return m; + } + +@@ -967,7 +993,7 @@ grabkeys(void) + void + incnmaster(const Arg *arg) + { +- selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); ++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0); + arrange(selmon); + } + +@@ -1502,9 +1528,9 @@ void + setlayout(const Arg *arg) + { + if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) +- selmon->sellt ^= 1; ++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1; + if (arg && arg->v) +- selmon->lt[selmon->sellt] = (Layout *)arg->v; ++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v; + strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); + if (selmon->sel) + arrange(selmon); +@@ -1523,7 +1549,7 @@ setmfact(const Arg *arg) + f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; + if (f < 0.05 || f > 0.95) + return; +- selmon->mfact = f; ++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f; + arrange(selmon); + } + +@@ -1702,7 +1728,7 @@ tile(Monitor *m) + void + togglebar(const Arg *arg) + { +- selmon->showbar = !selmon->showbar; ++ selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar; + updatebarpos(selmon); + XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); + arrange(selmon); +@@ -1741,9 +1767,33 @@ void + toggleview(const Arg *arg) + { + unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK); ++ int i; + + if (newtagset) { + selmon->tagset[selmon->seltags] = newtagset; ++ ++ if (newtagset == ~0) { ++ selmon->pertag->prevtag = selmon->pertag->curtag; ++ selmon->pertag->curtag = 0; ++ } ++ ++ /* test if the user did not select the same tag */ ++ if (!(newtagset & 1 << (selmon->pertag->curtag - 1))) { ++ selmon->pertag->prevtag = selmon->pertag->curtag; ++ for (i = 0; !(newtagset & 1 << i); i++) ; ++ selmon->pertag->curtag = i + 1; ++ } ++ ++ /* apply settings for this view */ ++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; ++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; ++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; ++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; ++ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; ++ ++ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) ++ togglebar(NULL); ++ + focus(NULL); + arrange(selmon); + } +@@ -2038,11 +2088,37 @@ updatewmhints(Client *c) + void + view(const Arg *arg) + { ++ int i; ++ unsigned int tmptag; ++ + if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) + return; + selmon->seltags ^= 1; /* toggle sel tagset */ +- if (arg->ui & TAGMASK) ++ if (arg->ui & TAGMASK) { + selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; ++ selmon->pertag->prevtag = selmon->pertag->curtag; ++ ++ if (arg->ui == ~0) ++ selmon->pertag->curtag = 0; ++ else { ++ for (i = 0; !(arg->ui & 1 << i); i++) ; ++ selmon->pertag->curtag = i + 1; ++ } ++ } else { ++ tmptag = selmon->pertag->prevtag; ++ selmon->pertag->prevtag = selmon->pertag->curtag; ++ selmon->pertag->curtag = tmptag; ++ } ++ ++ selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; ++ selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; ++ selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; ++ selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; ++ selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; ++ ++ if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) ++ togglebar(NULL); ++ + focus(NULL); + arrange(selmon); + } diff --git a/.local/src/dwm/rules.h b/.local/src/dwm/rules.h index 971e2ccd..e7a11d8a 100644 --- a/.local/src/dwm/rules.h +++ b/.local/src/dwm/rules.h @@ -17,7 +17,7 @@ */ static const Rule rules[] = { - /* class instance title tags mask isfloating floatpos isterminal noswallow monitor */ + /* class instance title tags mask isfloating floatpos isterminal noswallow monitor */ { "discord" , NULL , NULL , 1 << 8 , NULL , NULL , 0 , 0 , -1 }, { "Brave-browser" , NULL , NULL , 1 << 1 , NULL , NULL , 0 , 0 , -1 }, { "firefox" , NULL , NULL , 1 << 1 , NULL , NULL , 0 , 0 , -1 }, @@ -37,6 +37,7 @@ static const Rule rules[] = { { "weather" , NULL , NULL , 0 , 1 , "50% 50% 1200W 800H" , 0 , 0 , -1 }, { "center" , NULL , NULL , 0 , 1 , "50% 50% 1000W 600H" , 0 , 0 , -1 }, { "htop" , NULL , NULL , 0 , 1 , "50% 50% 1200W 600H" , 0 , 0 , -1 }, +{ "Zathura" , NULL , NULL , 0 , 0 , NULL , 0 , 1 , -1 }, { "spfeh" , NULL , NULL , SPTAG(1) , 1 , NULL , 0 , 0 , -1 }, { NULL , "spterm" , NULL , SPTAG(0) , 1 , NULL , 0 , 0 , -1 }, { NULL , "spmutt" , NULL , SPTAG(2) , 1 , NULL , 0 , 0 , -1 }, diff --git a/.local/src/sent/config.def.h b/.local/src/sent/config.def.h index 60eb376d..c8a66ddf 100644 --- a/.local/src/sent/config.def.h +++ b/.local/src/sent/config.def.h @@ -13,12 +13,20 @@ static const char *colors[] = { "#FFFFFF", /* background color */ }; +static const char *inverted_colors[] = { + "#FFFFFF", /* foreground color */ + "#000000", /* background color */ +}; + static const float linespacing = 1.4; /* how much screen estate is to be used at max for the content */ static const float usablewidth = 0.75; static const float usableheight = 0.75; +/* height of the presentation progress bar */ +static const int progressheight = 5; + static Mousekey mshortcuts[] = { /* button function argument */ { Button1, advance, {.i = +1} }, @@ -47,6 +55,7 @@ static Shortcut shortcuts[] = { { XK_n, advance, {.i = +1} }, { XK_p, advance, {.i = -1} }, { XK_r, reload, {0} }, + { XK_i, togglescm, {0} }, }; static Filter filters[] = { diff --git a/.local/src/sent/config.h b/.local/src/sent/config.h index 39bd98ee..c8a66ddf 100644 --- a/.local/src/sent/config.h +++ b/.local/src/sent/config.h @@ -9,6 +9,11 @@ static char *fontfallbacks[] = { #define FONTSZ(x) ((int)(10.0 * powf(1.1288, (x)))) /* x in [0, NUMFONTSCALES-1] */ static const char *colors[] = { + "#000000", /* foreground color */ + "#FFFFFF", /* background color */ +}; + +static const char *inverted_colors[] = { "#FFFFFF", /* foreground color */ "#000000", /* background color */ }; @@ -19,6 +24,9 @@ static const float linespacing = 1.4; static const float usablewidth = 0.75; static const float usableheight = 0.75; +/* height of the presentation progress bar */ +static const int progressheight = 5; + static Mousekey mshortcuts[] = { /* button function argument */ { Button1, advance, {.i = +1} }, @@ -47,6 +55,7 @@ static Shortcut shortcuts[] = { { XK_n, advance, {.i = +1} }, { XK_p, advance, {.i = -1} }, { XK_r, reload, {0} }, + { XK_i, togglescm, {0} }, }; static Filter filters[] = { diff --git a/.local/src/sent/example b/.local/src/sent/example new file mode 100644 index 00000000..300577a4 --- /dev/null +++ b/.local/src/sent/example @@ -0,0 +1,69 @@ +sent + +Origin: + Takahashi + +Why? +• PPTX sucks +• LATEX sucks +• PDF sucks + +also: +terminal presentations +don't support images… + +@nyan.png +this text will not be displayed, since the @ at the start of the first line +makes this paragraph an image slide. + +easy to use + +depends on +♽ Xlib +☢ Xft +☃ farbfeld + +~1000 lines of code + +usage: +$ sent FILE1 [FILE2 …] + +▸ one slide per paragraph +▸ lines starting with # are ignored +▸ image slide: paragraph containing @FILENAME +▸ empty slide: just use a \ as a paragraph + +# This is a comment and will not be part of the presentation + +# multiple empty lines between paragraphs are also ignored + + +# The following lines should produce +# one empty slide + + + +\ +\ + +\@this_line_actually_started_with_a_\.png +\#This line as well +⇒ Prepend a backslash to kill behaviour of special characters + +Images are handled in the +http://tools.suckless.org/farbfeld/ +format internally. + +sent also supports transparent images. +Try changing the background in config.h +and rebuild. + +@transparent_test.ff + +😀😁😂😃😄😅😆😇😈😉😊😋😌😍😎😏 +😐😑😒😓😔😕😖😗😘😙😚😛😜😝😞😟 +😠😡😢😣😥😦😧😨😩😪😫😭😮😯😰😱 +😲😳😴😵😶😷😸😹😺😻😼😽😾😿🙀☠ + +thanks. +questions? diff --git a/.local/src/sent/nyan.png b/.local/src/sent/nyan.png new file mode 100644 index 00000000..377b9d08 Binary files /dev/null and b/.local/src/sent/nyan.png differ diff --git a/.local/src/sent/patches/sent-invertedcolors-72d33d4.diff b/.local/src/sent/patches/sent-invertedcolors-72d33d4.diff new file mode 100644 index 00000000..2da5fc5f --- /dev/null +++ b/.local/src/sent/patches/sent-invertedcolors-72d33d4.diff @@ -0,0 +1,73 @@ +diff --git a/config.def.h b/config.def.h +index 60eb376..ccea9a6 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -13,6 +13,11 @@ static const char *colors[] = { + "#FFFFFF", /* background color */ + }; + ++static const char *inverted_colors[] = { ++ "#FFFFFF", /* foreground color */ ++ "#000000", /* background color */ ++}; ++ + static const float linespacing = 1.4; + + /* how much screen estate is to be used at max for the content */ +diff --git a/sent.1 b/sent.1 +index fabc614..f74d583 100644 +--- a/sent.1 ++++ b/sent.1 +@@ -6,6 +6,7 @@ + .Sh SYNOPSIS + .Nm + .Op Fl v ++.Op Fl i + .Op Ar file + .Sh DESCRIPTION + .Nm +@@ -21,6 +22,8 @@ few minutes. + .Bl -tag -width Ds + .It Fl v + Print version information to stdout and exit. ++.It Fl i ++Use the colors from the inverted color array. + .El + .Sh USAGE + .Bl -tag -width Ds +diff --git a/sent.c b/sent.c +index c50a572..c31f772 100644 +--- a/sent.c ++++ b/sent.c +@@ -25,6 +25,8 @@ + + char *argv0; + ++int use_inverted_colors = 0; ++ + /* macros */ + #define LEN(a) (sizeof(a) / sizeof(a)[0]) + #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) +@@ -586,7 +588,11 @@ xinit() + + if (!(d = drw_create(xw.dpy, xw.scr, xw.win, xw.w, xw.h))) + die("sent: Unable to create drawing context"); +- sc = drw_scm_create(d, colors, 2); ++ if (use_inverted_colors) { ++ sc = drw_scm_create(d, inverted_colors, 2); ++ } else { ++ sc = drw_scm_create(d, colors, 2); ++ } + drw_setscheme(d, sc); + XSetWindowBackground(xw.dpy, xw.win, sc[ColBg].pixel); + +@@ -687,6 +693,9 @@ main(int argc, char *argv[]) + case 'v': + fprintf(stderr, "sent-"VERSION"\n"); + return 0; ++ case 'i': ++ use_inverted_colors = 1; ++ break; + default: + usage(); + } ARGEND diff --git a/.local/src/sent/patches/sent-options-20190213-72d33d4.diff b/.local/src/sent/patches/sent-options-20190213-72d33d4.diff new file mode 100644 index 00000000..d13df48e --- /dev/null +++ b/.local/src/sent/patches/sent-options-20190213-72d33d4.diff @@ -0,0 +1,72 @@ +From 3a348cc15a97df8e8784b129800293dcfba28f3f Mon Sep 17 00:00:00 2001 +From: Sunur Efe Vural +Date: Wed, 13 Feb 2019 14:28:17 -0500 +Subject: [PATCH] Commandline Options + +A simple patch that adds extra commandline options to sent. +--- + sent.1 | 11 +++++++++++ + sent.c | 11 ++++++++++- + 2 files changed, 21 insertions(+), 1 deletion(-) + +diff --git a/sent.1 b/sent.1 +index fabc614..5d55bf4 100644 +--- a/sent.1 ++++ b/sent.1 +@@ -5,6 +5,9 @@ + .Nd simple plaintext presentation tool + .Sh SYNOPSIS + .Nm ++.Op Fl f Ar font ++.Op Fl c Ar fgcolor ++.Op Fl b Ar bgcolor + .Op Fl v + .Op Ar file + .Sh DESCRIPTION +@@ -21,6 +24,14 @@ few minutes. + .Bl -tag -width Ds + .It Fl v + Print version information to stdout and exit. ++.It Fl f Ar font ++Defines the ++.Ar font ++when sent is run. ++.It Fl c Ar fgcolor ++Defines the foreground color when sent is run. ++.It Fl b Ar bgcolor ++Defines the background color when sent is run. + .El + .Sh USAGE + .Bl -tag -width Ds +diff --git a/sent.c b/sent.c +index c50a572..0b36e32 100644 +--- a/sent.c ++++ b/sent.c +@@ -675,7 +675,7 @@ configure(XEvent *e) + void + usage() + { +- die("usage: %s [file]", argv0); ++ die("usage: %s [-c fgcolor] [-b bgcolor] [-f font] [file]", argv0); + } + + int +@@ -687,6 +687,15 @@ main(int argc, char *argv[]) + case 'v': + fprintf(stderr, "sent-"VERSION"\n"); + return 0; ++ case 'f': ++ fontfallbacks[0] = EARGF(usage()); ++ break; ++ case 'c': ++ colors[0] = EARGF(usage()); ++ break; ++ case 'b': ++ colors[1] = EARGF(usage()); ++ break; + default: + usage(); + } ARGEND +-- +2.20.1 + diff --git a/.local/src/sent/patches/sent-progress-bar-1.0.diff b/.local/src/sent/patches/sent-progress-bar-1.0.diff new file mode 100644 index 00000000..9d0e7d2d --- /dev/null +++ b/.local/src/sent/patches/sent-progress-bar-1.0.diff @@ -0,0 +1,31 @@ +diff --git a/config.def.h b/config.def.h +index 60eb376..25d89e0 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -19,6 +19,9 @@ static const float linespacing = 1.4; + static const float usablewidth = 0.75; + static const float usableheight = 0.75; + ++/* height of the presentation progress bar */ ++static const int progressheight = 5; ++ + static Mousekey mshortcuts[] = { + /* button function argument */ + { Button1, advance, {.i = +1} }, +diff --git a/sent.c b/sent.c +index c50a572..046466e 100644 +--- a/sent.c ++++ b/sent.c +@@ -533,6 +533,12 @@ xdraw() + 0, + slides[idx].lines[i], + 0); ++ if (idx != 0 && progressheight != 0) { ++ drw_rect(d, ++ 0, xw.h - progressheight, ++ (xw.w * idx)/(slidecount - 1), progressheight, ++ 1, 0); ++ } + drw_map(d, xw.win, 0, 0, xw.w, xw.h); + } else { + if (!(im->state & SCALED)) diff --git a/.local/src/sent/patches/sent-toggle-scm-20210119-2be4210.diff b/.local/src/sent/patches/sent-toggle-scm-20210119-2be4210.diff new file mode 100644 index 00000000..12ba579c --- /dev/null +++ b/.local/src/sent/patches/sent-toggle-scm-20210119-2be4210.diff @@ -0,0 +1,79 @@ +From 2be4210944d97ddb158feee601ec85c016de0872 Mon Sep 17 00:00:00 2001 +From: Randoragon +Date: Tue, 19 Jan 2021 10:17:47 +0100 +Subject: [PATCH] Add toggle colorscheme functionality + +This patch is meant to be applied on top of the "inverted colors" patch +(https://tools.suckless.org/sent/patches/inverted-colors/). It creates a +new binding, "i", that lets you toggle between two colorschemes during +presentation. +--- + config.def.h | 1 + + sent.1 | 2 ++ + sent.c | 18 ++++++++++++++++++ + 3 files changed, 21 insertions(+) + +diff --git a/config.def.h b/config.def.h +index ccea9a6..c72afc5 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -52,6 +52,7 @@ static Shortcut shortcuts[] = { + { XK_n, advance, {.i = +1} }, + { XK_p, advance, {.i = -1} }, + { XK_r, reload, {0} }, ++ { XK_i, togglescm, {0} }, + }; + + static Filter filters[] = { +diff --git a/sent.1 b/sent.1 +index f74d583..a7564a8 100644 +--- a/sent.1 ++++ b/sent.1 +@@ -44,6 +44,8 @@ Reload the slides. Only works on file input. + Go to next slide, if existent. + .It Sy Left | Backspace | h | k | Up | Prior | p + Go to previous slide, if existent. ++.It Sy i ++Toggle colorschemes. + .El + .El + .Sh FORMAT +diff --git a/sent.c b/sent.c +index 7053ab3..d29fc35 100644 +--- a/sent.c ++++ b/sent.c +@@ -107,6 +107,7 @@ static void xdraw(); + static void xhints(); + static void xinit(); + static void xloadfonts(); ++static void togglescm(); + + static void bpress(XEvent *); + static void cmessage(XEvent *); +@@ -613,6 +614,23 @@ xinit() + XSync(xw.dpy, False); + } + ++void ++togglescm() ++{ ++ if (use_inverted_colors) { ++ free(sc); ++ sc = drw_scm_create(d, colors, 2); ++ use_inverted_colors = 0; ++ } else { ++ sc = drw_scm_create(d, inverted_colors, 2); ++ use_inverted_colors = 1; ++ } ++ drw_setscheme(d, sc); ++ XSetWindowBackground(xw.dpy, xw.win, sc[ColBg].pixel); ++ xdraw(); ++} ++ ++ + void + xloadfonts() + { +-- +2.30.0 + diff --git a/.local/src/sent/sent b/.local/src/sent/sent index 1cd1f598..43c6a65f 100755 Binary files a/.local/src/sent/sent and b/.local/src/sent/sent differ diff --git a/.local/src/sent/sent.1 b/.local/src/sent/sent.1 index fabc6141..c1976f3a 100644 --- a/.local/src/sent/sent.1 +++ b/.local/src/sent/sent.1 @@ -5,7 +5,11 @@ .Nd simple plaintext presentation tool .Sh SYNOPSIS .Nm +.Op Fl f Ar font +.Op Fl c Ar fgcolor +.Op Fl b Ar bgcolor .Op Fl v +.Op Fl i .Op Ar file .Sh DESCRIPTION .Nm @@ -21,6 +25,17 @@ few minutes. .Bl -tag -width Ds .It Fl v Print version information to stdout and exit. +.It Fl i +Use the colors from the inverted color array. +.It Fl f Ar font +Defines the +.Ar font +when sent is run. +.It Fl c Ar fgcolor +Defines the foreground color when sent is run. +.It Fl b Ar bgcolor +Defines the background color when sent is run. +>>>>>>> .El .Sh USAGE .Bl -tag -width Ds @@ -41,6 +56,8 @@ Reload the slides. Only works on file input. Go to next slide, if existent. .It Sy Left | Backspace | h | k | Up | Prior | p Go to previous slide, if existent. +.It Sy i +Toggle colorschemes. .El .El .Sh FORMAT diff --git a/.local/src/sent/sent.c b/.local/src/sent/sent.c index 9534fcaf..c439dd3a 100644 --- a/.local/src/sent/sent.c +++ b/.local/src/sent/sent.c @@ -25,6 +25,8 @@ char *argv0; +int use_inverted_colors = 0; + /* macros */ #define LEN(a) (sizeof(a) / sizeof(a)[0]) #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) @@ -105,6 +107,7 @@ static void xdraw(); static void xhints(); static void xinit(); static void xloadfonts(); +static void togglescm(); static void bpress(XEvent *); static void cmessage(XEvent *); @@ -537,6 +540,12 @@ xdraw() 0, slides[idx].lines[i], 0); + if (idx != 0 && progressheight != 0) { + drw_rect(d, + 0, xw.h - progressheight, + (xw.w * idx)/(slidecount - 1), progressheight, + 1, 0); + } drw_map(d, xw.win, 0, 0, xw.w, xw.h); } else { if (!(im->state & SCALED)) @@ -590,7 +599,11 @@ xinit() if (!(d = drw_create(xw.dpy, xw.scr, xw.win, xw.w, xw.h))) die("sent: Unable to create drawing context"); - sc = drw_scm_create(d, colors, 2); + if (use_inverted_colors) { + sc = drw_scm_create(d, inverted_colors, 2); + } else { + sc = drw_scm_create(d, colors, 2); + } drw_setscheme(d, sc); XSetWindowBackground(xw.dpy, xw.win, sc[ColBg].pixel); @@ -607,6 +620,23 @@ xinit() XSync(xw.dpy, False); } +void +togglescm() +{ + if (use_inverted_colors) { + free(sc); + sc = drw_scm_create(d, colors, 2); + use_inverted_colors = 0; + } else { + sc = drw_scm_create(d, inverted_colors, 2); + use_inverted_colors = 1; + } + drw_setscheme(d, sc); + XSetWindowBackground(xw.dpy, xw.win, sc[ColBg].pixel); + xdraw(); +} + + void xloadfonts() { @@ -679,7 +709,7 @@ configure(XEvent *e) void usage() { - die("usage: %s [file]", argv0); + die("usage: %s [-c fgcolor] [-b bgcolor] [-f font] [file]", argv0); } int @@ -691,6 +721,17 @@ main(int argc, char *argv[]) case 'v': fprintf(stderr, "sent-"VERSION"\n"); return 0; + case 'i': + use_inverted_colors = 1; + case 'f': + fontfallbacks[0] = EARGF(usage()); + break; + case 'c': + colors[0] = EARGF(usage()); + break; + case 'b': + colors[1] = EARGF(usage()); + break; default: usage(); } ARGEND