@ -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 |
@ -0,0 +1,240 @@ | |||
From d94cb6f1a553d19127f44dbdc96e8bb5041956c2 Mon Sep 17 00:00:00 2001 | |||
From: Nihal Jere <noocsharp@gmail.com> | |||
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:<signame> [<type> <value>]"` */ | |||
+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 | |||
@ -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); | |||
} |
@ -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? |
@ -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 |
@ -0,0 +1,72 @@ | |||
From 3a348cc15a97df8e8784b129800293dcfba28f3f Mon Sep 17 00:00:00 2001 | |||
From: Sunur Efe Vural <efe@efe.kim> | |||
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 | |||
@ -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)) |
@ -0,0 +1,79 @@ | |||
From 2be4210944d97ddb158feee601ec85c016de0872 Mon Sep 17 00:00:00 2001 | |||
From: Randoragon <randoragongamedev@gmail.com> | |||
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 | |||