Project cleanup
This commit is contained in:
parent
2718965e66
commit
986e599eda
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,8 +1,9 @@
|
|||||||
*.tar.gz
|
*.tar.gz
|
||||||
*.o
|
*.o
|
||||||
dmenu
|
dmenu
|
||||||
dmenu_path
|
|
||||||
dmenu_run
|
|
||||||
stest
|
stest
|
||||||
st
|
st
|
||||||
dwm
|
dwm
|
||||||
|
slock
|
||||||
|
config.h
|
||||||
|
blocks.h
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
|
||||||
/* Default settings; can be overriden by command line. */
|
|
||||||
|
|
||||||
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
|
||||||
static int centered = 1; /* -c option; centers dmenu on screen */
|
|
||||||
static int min_width = 550; /* minimum width when centered */
|
|
||||||
/* -fn option overrides fonts[0]; default X11 font or font set */
|
|
||||||
static const char *fonts[] = {
|
|
||||||
"MesloLGS NF:size=11"
|
|
||||||
};
|
|
||||||
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
|
||||||
static const char *colors[SchemeLast][2] = {
|
|
||||||
/* fg bg */
|
|
||||||
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
|
||||||
[SchemeSel] = { "#eeeeee", "#408977" },
|
|
||||||
[SchemeSelHighlight] = { "#ffc978", "#408977" },
|
|
||||||
[SchemeNormHighlight] = { "#ffc978", "#222222" },
|
|
||||||
[SchemeOut] = { "#000000", "#00ffff" },
|
|
||||||
[SchemeOutHighlight] = { "#ffc978", "#00ffff" },
|
|
||||||
};
|
|
||||||
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
|
||||||
static unsigned int lines = 12;
|
|
||||||
/* -h option; minimum height of a menu line */
|
|
||||||
static unsigned int lineheight = 0;
|
|
||||||
static unsigned int min_lineheight = 8;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Characters not considered part of a word while deleting words
|
|
||||||
* for example: " /?\"&[]"
|
|
||||||
*/
|
|
||||||
static const char worddelimiters[] = " ";
|
|
||||||
|
|
||||||
/* Size of the window border */
|
|
||||||
static const unsigned int border_width = 5;
|
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
/* appearance */
|
/* appearance */
|
||||||
static const unsigned int borderpx = 2; /* border pixel of windows */
|
static const unsigned int borderpx = 2; /* border pixel of windows */
|
||||||
static const unsigned int gappx = 6; /* gaps between windows */
|
static const unsigned int gappx = 8; /* gaps between windows */
|
||||||
static const unsigned int snap = 32; /* snap pixel */
|
static const unsigned int snap = 32; /* snap pixel */
|
||||||
static const int showbar = 1; /* 0 means no bar */
|
static const int showbar = 1; /* 0 means no bar */
|
||||||
static const int topbar = 1; /* 0 means bottom bar */
|
static const int topbar = 1; /* 0 means bottom bar */
|
||||||
@ -25,7 +25,7 @@ static const char *colors[][3] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* tagging */
|
/* tagging */
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "9" };
|
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
||||||
|
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
/* xprop(1):
|
/* xprop(1):
|
||||||
@ -67,6 +67,7 @@ static const char *termcmd[] = { "st", NULL };
|
|||||||
|
|
||||||
/* Own commands */
|
/* Own commands */
|
||||||
static const char *screenshot[] = { "makescreenshot", NULL };
|
static const char *screenshot[] = { "makescreenshot", NULL };
|
||||||
|
static const char *slock[] = { "slock", NULL };
|
||||||
|
|
||||||
|
|
||||||
static Key keys[] = {
|
static Key keys[] = {
|
||||||
@ -78,8 +79,8 @@ static Key keys[] = {
|
|||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
||||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
||||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
{ MODKEY, XK_Left, setmfact, {.f = -0.05} },
|
||||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
{ MODKEY, XK_Right, setmfact, {.f = +0.05} },
|
||||||
{ MODKEY, XK_Return, zoom, {0} },
|
{ MODKEY, XK_Return, zoom, {0} },
|
||||||
{ MODKEY, XK_Tab, view, {0} },
|
{ MODKEY, XK_Tab, view, {0} },
|
||||||
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
|
||||||
@ -94,10 +95,11 @@ static Key keys[] = {
|
|||||||
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
{ MODKEY, XK_period, focusmon, {.i = +1 } },
|
||||||
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
|
||||||
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
|
||||||
{ MODKEY, XK_minus, setgaps, {.i = -1 } },
|
{ MODKEY, XK_Up, setgaps, {.i = -2 } },
|
||||||
{ MODKEY, XK_equal, setgaps, {.i = +1 } },
|
{ MODKEY, XK_Down, setgaps, {.i = +2 } },
|
||||||
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
{ MODKEY|ShiftMask, XK_Up, setgaps, {.i = 0 } },
|
||||||
{ MODKEY|ShiftMask, XK_s, spawn, {.v = screenshot } },
|
{ MODKEY|ShiftMask, XK_s, spawn, {.v = screenshot } },
|
||||||
|
{ MODKEY, XK_l, spawn, {.v = slock } },
|
||||||
TAGKEYS( XK_1, 0)
|
TAGKEYS( XK_1, 0)
|
||||||
TAGKEYS( XK_2, 1)
|
TAGKEYS( XK_2, 1)
|
||||||
TAGKEYS( XK_3, 2)
|
TAGKEYS( XK_3, 2)
|
||||||
|
129
dwm-6.2/config.h
129
dwm-6.2/config.h
@ -1,129 +0,0 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
|
||||||
|
|
||||||
/* appearance */
|
|
||||||
static const unsigned int borderpx = 2; /* border pixel of windows */
|
|
||||||
static const unsigned int gappx = 6; /* gaps between 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[] = { "MesloLGS NF:size=11" };
|
|
||||||
static const char dmenufont[] = "MesloLGS NF:size=11";
|
|
||||||
static const char dmenupromt[] = "Run:";
|
|
||||||
/*
|
|
||||||
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_teal[] = "#408977";
|
|
||||||
static const char *colors[][3] = {
|
|
||||||
/* fg bg border */
|
|
||||||
[SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
|
|
||||||
[SchemeSel] = { col_gray4, col_teal, col_teal },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* tagging */
|
|
||||||
static const char *tags[] = { "1", "2", "3", "4", "9" };
|
|
||||||
|
|
||||||
static const Rule rules[] = {
|
|
||||||
/* xprop(1):
|
|
||||||
* WM_CLASS(STRING) = instance, class
|
|
||||||
* WM_NAME(STRING) = title
|
|
||||||
*/
|
|
||||||
/* class instance title tags mask isfloating monitor */
|
|
||||||
{ "Gimp", NULL, NULL, 0, 1, -1 },
|
|
||||||
{ "Firefox", NULL, NULL, 1 << 8, 0, -1 },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* layout(s) */
|
|
||||||
static const float mfact = 0.5; /* factor of master area size [0.05..0.95] */
|
|
||||||
static const int nmaster = 1; /* number of clients in master area */
|
|
||||||
static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
|
|
||||||
|
|
||||||
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_teal, "-sf", col_gray4, "-p", dmenupromt, NULL};
|
|
||||||
static const char *termcmd[] = { "st", NULL };
|
|
||||||
|
|
||||||
/* Own commands */
|
|
||||||
static const char *screenshot[] = { "makescreenshot", NULL };
|
|
||||||
|
|
||||||
|
|
||||||
static Key keys[] = {
|
|
||||||
/* modifier key function argument */
|
|
||||||
{ MODKEY, XK_p, spawn, {.v = dmenucmd } },
|
|
||||||
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
|
|
||||||
{ MODKEY, XK_b, togglebar, {0} },
|
|
||||||
{ MODKEY, XK_j, focusstack, {.i = +1 } },
|
|
||||||
{ MODKEY, XK_k, focusstack, {.i = -1 } },
|
|
||||||
{ MODKEY, XK_i, incnmaster, {.i = +1 } },
|
|
||||||
{ MODKEY, XK_d, incnmaster, {.i = -1 } },
|
|
||||||
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
|
|
||||||
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
|
|
||||||
{ MODKEY, 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_minus, setgaps, {.i = -1 } },
|
|
||||||
{ MODKEY, XK_equal, setgaps, {.i = +1 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
|
|
||||||
{ MODKEY|ShiftMask, XK_s, spawn, {.v = screenshot } },
|
|
||||||
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, XK_q, quit, {0} },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* button definitions */
|
|
||||||
/* click can be ClkTagBar, 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} },
|
|
||||||
};
|
|
||||||
|
|
@ -4,6 +4,7 @@ static const Block blocks[] = {
|
|||||||
{"", "dwmmemory", 10, 0},
|
{"", "dwmmemory", 10, 0},
|
||||||
{"", "dwmcpu", 5, 0},
|
{"", "dwmcpu", 5, 0},
|
||||||
{"", "dwmnetwork", 5, 0},
|
{"", "dwmnetwork", 5, 0},
|
||||||
|
{"", "dwmnetspeed", 5, 0},
|
||||||
{"", "dwmdisk", 600, 0},
|
{"", "dwmdisk", 600, 0},
|
||||||
/* Battery not needed on desktop system {"", "dwmbatterdwmbattery, 0}, */
|
/* Battery not needed on desktop system {"", "dwmbatterdwmbattery, 0}, */
|
||||||
{" ", "date '+%b %d %H:%M'", 5, 0},
|
{" ", "date '+%b %d %H:%M'", 5, 0},
|
||||||
|
24
slock-1.4/LICENSE
Normal file
24
slock-1.4/LICENSE
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
MIT/X Consortium License
|
||||||
|
|
||||||
|
© 2015-2016 Markus Teich <markus.teich@stusta.mhn.de>
|
||||||
|
© 2014 Dimitris Papastamos <sin@2f30.org>
|
||||||
|
© 2006-2014 Anselm R Garbe <anselm@garbe.us>
|
||||||
|
© 2014-2016 Laslo Hunhold <dev@frign.de>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
61
slock-1.4/Makefile
Normal file
61
slock-1.4/Makefile
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
# slock - simple screen locker
|
||||||
|
# See LICENSE file for copyright and license details.
|
||||||
|
|
||||||
|
include config.mk
|
||||||
|
|
||||||
|
SRC = slock.c ${COMPATSRC}
|
||||||
|
OBJ = ${SRC:.c=.o}
|
||||||
|
|
||||||
|
all: options slock
|
||||||
|
|
||||||
|
options:
|
||||||
|
@echo slock build options:
|
||||||
|
@echo "CFLAGS = ${CFLAGS}"
|
||||||
|
@echo "LDFLAGS = ${LDFLAGS}"
|
||||||
|
@echo "CC = ${CC}"
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
@echo CC $<
|
||||||
|
@${CC} -c ${CFLAGS} $<
|
||||||
|
|
||||||
|
${OBJ}: config.h config.mk arg.h util.h
|
||||||
|
|
||||||
|
config.h:
|
||||||
|
@echo creating $@ from config.def.h
|
||||||
|
@cp config.def.h $@
|
||||||
|
|
||||||
|
slock: ${OBJ}
|
||||||
|
@echo CC -o $@
|
||||||
|
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@echo cleaning
|
||||||
|
@rm -f slock ${OBJ} slock-${VERSION}.tar.gz
|
||||||
|
|
||||||
|
dist: clean
|
||||||
|
@echo creating dist tarball
|
||||||
|
@mkdir -p slock-${VERSION}
|
||||||
|
@cp -R LICENSE Makefile README slock.1 config.mk \
|
||||||
|
${SRC} explicit_bzero.c config.def.h arg.h util.h slock-${VERSION}
|
||||||
|
@tar -cf slock-${VERSION}.tar slock-${VERSION}
|
||||||
|
@gzip slock-${VERSION}.tar
|
||||||
|
@rm -rf slock-${VERSION}
|
||||||
|
|
||||||
|
install: all
|
||||||
|
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
|
||||||
|
@mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||||
|
@cp -f slock ${DESTDIR}${PREFIX}/bin
|
||||||
|
@chmod 755 ${DESTDIR}${PREFIX}/bin/slock
|
||||||
|
@chmod u+s ${DESTDIR}${PREFIX}/bin/slock
|
||||||
|
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
|
||||||
|
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||||
|
@sed "s/VERSION/${VERSION}/g" <slock.1 >${DESTDIR}${MANPREFIX}/man1/slock.1
|
||||||
|
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/slock.1
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
|
||||||
|
@rm -f ${DESTDIR}${PREFIX}/bin/slock
|
||||||
|
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
|
||||||
|
@rm -f ${DESTDIR}${MANPREFIX}/man1/slock.1
|
||||||
|
|
||||||
|
.PHONY: all options clean dist install uninstall
|
24
slock-1.4/README
Normal file
24
slock-1.4/README
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
slock - simple screen locker
|
||||||
|
============================
|
||||||
|
simple screen locker utility for X.
|
||||||
|
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
In order to build slock you need the Xlib header files.
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
Edit config.mk to match your local setup (slock is installed into
|
||||||
|
the /usr/local namespace by default).
|
||||||
|
|
||||||
|
Afterwards enter the following command to build and install slock
|
||||||
|
(if necessary as root):
|
||||||
|
|
||||||
|
make clean install
|
||||||
|
|
||||||
|
|
||||||
|
Running slock
|
||||||
|
-------------
|
||||||
|
Simply invoke the 'slock' command. To get out of it, enter your password.
|
65
slock-1.4/arg.h
Normal file
65
slock-1.4/arg.h
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* Copy me if you can.
|
||||||
|
* by 20h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ARG_H__
|
||||||
|
#define ARG_H__
|
||||||
|
|
||||||
|
extern char *argv0;
|
||||||
|
|
||||||
|
/* use main(int argc, char *argv[]) */
|
||||||
|
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
|
||||||
|
argv[0] && argv[0][0] == '-'\
|
||||||
|
&& argv[0][1];\
|
||||||
|
argc--, argv++) {\
|
||||||
|
char argc_;\
|
||||||
|
char **argv_;\
|
||||||
|
int brk_;\
|
||||||
|
if (argv[0][1] == '-' && argv[0][2] == '\0') {\
|
||||||
|
argv++;\
|
||||||
|
argc--;\
|
||||||
|
break;\
|
||||||
|
}\
|
||||||
|
for (brk_ = 0, argv[0]++, argv_ = argv;\
|
||||||
|
argv[0][0] && !brk_;\
|
||||||
|
argv[0]++) {\
|
||||||
|
if (argv_ != argv)\
|
||||||
|
break;\
|
||||||
|
argc_ = argv[0][0];\
|
||||||
|
switch (argc_)
|
||||||
|
|
||||||
|
/* Handles obsolete -NUM syntax */
|
||||||
|
#define ARGNUM case '0':\
|
||||||
|
case '1':\
|
||||||
|
case '2':\
|
||||||
|
case '3':\
|
||||||
|
case '4':\
|
||||||
|
case '5':\
|
||||||
|
case '6':\
|
||||||
|
case '7':\
|
||||||
|
case '8':\
|
||||||
|
case '9'
|
||||||
|
|
||||||
|
#define ARGEND }\
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ARGC() argc_
|
||||||
|
|
||||||
|
#define ARGNUMF() (brk_ = 1, estrtonum(argv[0], 0, INT_MAX))
|
||||||
|
|
||||||
|
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
||||||
|
((x), abort(), (char *)0) :\
|
||||||
|
(brk_ = 1, (argv[0][1] != '\0')?\
|
||||||
|
(&argv[0][1]) :\
|
||||||
|
(argc--, argv++, argv[0])))
|
||||||
|
|
||||||
|
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
||||||
|
(char *)0 :\
|
||||||
|
(brk_ = 1, (argv[0][1] != '\0')?\
|
||||||
|
(&argv[0][1]) :\
|
||||||
|
(argc--, argv++, argv[0])))
|
||||||
|
|
||||||
|
#define LNGARG() &argv[0][0]
|
||||||
|
|
||||||
|
#endif
|
33
slock-1.4/config.def.h
Normal file
33
slock-1.4/config.def.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/* user and group to drop privileges to */
|
||||||
|
static const char *user = "n0x";
|
||||||
|
static const char *group = "n0x";
|
||||||
|
|
||||||
|
static const char *colorname[NUMCOLS] = {
|
||||||
|
[INIT] = "black", /* after initialization */
|
||||||
|
[INPUT] = "#005577", /* during input */
|
||||||
|
[FAILED] = "#CC3333", /* wrong password */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* treat a cleared input like a wrong password (color) */
|
||||||
|
static const int failonclear = 1;
|
||||||
|
|
||||||
|
/* default message */
|
||||||
|
static const char * message = "Suckless: Software that sucks less.";
|
||||||
|
|
||||||
|
/* text color */
|
||||||
|
static const char * text_color = "#ffffff";
|
||||||
|
|
||||||
|
/* text size (must be a valid size) */
|
||||||
|
static const char * font_name = "6x13";
|
||||||
|
|
||||||
|
/* time in seconds to cancel lock with mouse movement */
|
||||||
|
static const int timetocancel = 5;
|
||||||
|
|
||||||
|
/*Enable blur*/
|
||||||
|
#define BLUR
|
||||||
|
/*Set blur radius*/
|
||||||
|
static const int blurRadius=10;
|
||||||
|
/*Enable Pixelation*/
|
||||||
|
//#define PIXELATION
|
||||||
|
/*Set pixelation radius*/
|
||||||
|
static const int pixelSize=2;
|
32
slock-1.4/config.mk
Normal file
32
slock-1.4/config.mk
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# slock version
|
||||||
|
VERSION = 1.4
|
||||||
|
|
||||||
|
# Customize below to fit your system
|
||||||
|
|
||||||
|
# paths
|
||||||
|
PREFIX = /usr/local
|
||||||
|
MANPREFIX = ${PREFIX}/share/man
|
||||||
|
|
||||||
|
X11INC = /usr/X11R6/include
|
||||||
|
X11LIB = /usr/X11R6/lib
|
||||||
|
|
||||||
|
# includes and libs
|
||||||
|
INCS = -I. -I/usr/include -I${X11INC}
|
||||||
|
LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lImlib2 -lXinerama
|
||||||
|
|
||||||
|
# flags
|
||||||
|
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H
|
||||||
|
CFLAGS = -std=c99 -pedantic -Wall -Ofast ${INCS} ${CPPFLAGS}
|
||||||
|
LDFLAGS = -s ${LIBS}
|
||||||
|
COMPATSRC = explicit_bzero.c
|
||||||
|
|
||||||
|
# On OpenBSD and Darwin remove -lcrypt from LIBS
|
||||||
|
#LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lXext -lXrandr
|
||||||
|
# On *BSD remove -DHAVE_SHADOW_H from CPPFLAGS
|
||||||
|
# On NetBSD add -D_NETBSD_SOURCE to CPPFLAGS
|
||||||
|
#CPPFLAGS = -DVERSION=\"${VERSION}\" -D_BSD_SOURCE -D_NETBSD_SOURCE
|
||||||
|
# On OpenBSD set COMPATSRC to empty
|
||||||
|
#COMPATSRC =
|
||||||
|
|
||||||
|
# compiler and linker
|
||||||
|
CC = cc
|
19
slock-1.4/explicit_bzero.c
Normal file
19
slock-1.4/explicit_bzero.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* $OpenBSD: explicit_bzero.c,v 1.3 2014/06/21 02:34:26 matthew Exp $ */
|
||||||
|
/*
|
||||||
|
* Public domain.
|
||||||
|
* Written by Matthew Dempsky.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
__attribute__((weak)) void
|
||||||
|
__explicit_bzero_hook(void *buf, size_t len)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
explicit_bzero(void *buf, size_t len)
|
||||||
|
{
|
||||||
|
memset(buf, 0, len);
|
||||||
|
__explicit_bzero_hook(buf, len);
|
||||||
|
}
|
356
slock-1.4/patches/slock-blur_pixelated_screen-1.4.diff
Normal file
356
slock-1.4/patches/slock-blur_pixelated_screen-1.4.diff
Normal file
@ -0,0 +1,356 @@
|
|||||||
|
From 36a4863f9a399740aaf8b1e01926485c0a055e1c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lars Niesen <iah71niesen@gso-koeln.de>
|
||||||
|
Date: Wed, 29 Apr 2020 13:52:42 +0200
|
||||||
|
Subject: [PATCH 1/8] Added Bg patch and screenshot capabilities
|
||||||
|
|
||||||
|
---
|
||||||
|
config.mk | 2 +-
|
||||||
|
slock.c | 35 +++++++++++++++++++++++++++++++----
|
||||||
|
2 files changed, 32 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.mk b/config.mk
|
||||||
|
index 74429ae..987819e 100644
|
||||||
|
--- a/config.mk
|
||||||
|
+++ b/config.mk
|
||||||
|
@@ -12,7 +12,7 @@ X11LIB = /usr/X11R6/lib
|
||||||
|
|
||||||
|
# includes and libs
|
||||||
|
INCS = -I. -I/usr/include -I${X11INC}
|
||||||
|
-LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr
|
||||||
|
+LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lImlib2
|
||||||
|
|
||||||
|
# flags
|
||||||
|
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H
|
||||||
|
diff --git a/slock.c b/slock.c
|
||||||
|
index 5ae738c..7c63f34 100644
|
||||||
|
--- a/slock.c
|
||||||
|
+++ b/slock.c
|
||||||
|
@@ -18,6 +18,7 @@
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
+#include <Imlib2.h>
|
||||||
|
|
||||||
|
#include "arg.h"
|
||||||
|
#include "util.h"
|
||||||
|
@@ -35,6 +36,7 @@ struct lock {
|
||||||
|
int screen;
|
||||||
|
Window root, win;
|
||||||
|
Pixmap pmap;
|
||||||
|
+ Pixmap bgmap;
|
||||||
|
unsigned long colors[NUMCOLS];
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -46,6 +48,8 @@ struct xrandr {
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
+Imlib_Image image;
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
die(const char *errstr, ...)
|
||||||
|
{
|
||||||
|
@@ -190,9 +194,10 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
|
||||||
|
color = len ? INPUT : ((failure || failonclear) ? FAILED : INIT);
|
||||||
|
if (running && oldc != color) {
|
||||||
|
for (screen = 0; screen < nscreens; screen++) {
|
||||||
|
- XSetWindowBackground(dpy,
|
||||||
|
- locks[screen]->win,
|
||||||
|
- locks[screen]->colors[color]);
|
||||||
|
+ if(locks[screen]->bgmap)
|
||||||
|
+ XSetWindowBackgroundPixmap(dpy, locks[screen]->win, locks[screen]->bgmap);
|
||||||
|
+ else
|
||||||
|
+ XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[0]);
|
||||||
|
XClearWindow(dpy, locks[screen]->win);
|
||||||
|
}
|
||||||
|
oldc = color;
|
||||||
|
@@ -235,6 +240,17 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
|
||||||
|
lock->screen = screen;
|
||||||
|
lock->root = RootWindow(dpy, lock->screen);
|
||||||
|
|
||||||
|
+ if(image)
|
||||||
|
+ {
|
||||||
|
+ lock->bgmap = XCreatePixmap(dpy, lock->root, DisplayWidth(dpy, lock->screen), DisplayHeight(dpy, lock->screen), DefaultDepth(dpy, lock->screen));
|
||||||
|
+ imlib_context_set_image(image);
|
||||||
|
+ imlib_context_set_display(dpy);
|
||||||
|
+ imlib_context_set_visual(DefaultVisual(dpy, lock->screen));
|
||||||
|
+ imlib_context_set_colormap(DefaultColormap(dpy, lock->screen));
|
||||||
|
+ imlib_context_set_drawable(lock->bgmap);
|
||||||
|
+ imlib_render_image_on_drawable(0, 0);
|
||||||
|
+ imlib_free_image();
|
||||||
|
+ }
|
||||||
|
for (i = 0; i < NUMCOLS; i++) {
|
||||||
|
XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen),
|
||||||
|
colorname[i], &color, &dummy);
|
||||||
|
@@ -251,6 +267,8 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
|
||||||
|
CopyFromParent,
|
||||||
|
DefaultVisual(dpy, lock->screen),
|
||||||
|
CWOverrideRedirect | CWBackPixel, &wa);
|
||||||
|
+ if(lock->bgmap)
|
||||||
|
+ XSetWindowBackgroundPixmap(dpy, lock->win, lock->bgmap);
|
||||||
|
lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8);
|
||||||
|
invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap,
|
||||||
|
&color, &color, 0, 0);
|
||||||
|
@@ -354,7 +372,16 @@ main(int argc, char **argv) {
|
||||||
|
die("slock: setgid: %s\n", strerror(errno));
|
||||||
|
if (setuid(duid) < 0)
|
||||||
|
die("slock: setuid: %s\n", strerror(errno));
|
||||||
|
-
|
||||||
|
+
|
||||||
|
+ /*Create screenshot Image*/
|
||||||
|
+ Screen *scr = ScreenOfDisplay(dpy, DefaultScreen(dpy));
|
||||||
|
+ image = imlib_create_image(scr->width,scr->height);
|
||||||
|
+ imlib_context_set_image(image);
|
||||||
|
+ imlib_context_set_display(dpy);
|
||||||
|
+ imlib_context_set_visual(DefaultVisual(dpy,0));
|
||||||
|
+ imlib_context_set_drawable(RootWindow(dpy,XScreenNumberOfScreen(scr)));
|
||||||
|
+ imlib_copy_drawable_to_image(0,0,0,scr->width,scr->height,0,0,1);
|
||||||
|
+
|
||||||
|
/* check for Xrandr support */
|
||||||
|
rr.active = XRRQueryExtension(dpy, &rr.evbase, &rr.errbase);
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
|
|
||||||
|
From 9d89604ac52b0949d047dae2f9b78cb5085ee1a2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lars Niesen <iah71niesen@gso-koeln.de>
|
||||||
|
Date: Wed, 29 Apr 2020 14:15:59 +0200
|
||||||
|
Subject: [PATCH 2/8] Added blur function
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 3 +++
|
||||||
|
slock.c | 3 ++-
|
||||||
|
2 files changed, 5 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index c8e52d6..fcc1b39 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -10,3 +10,6 @@ static const char *colorname[NUMCOLS] = {
|
||||||
|
|
||||||
|
/* treat a cleared input like a wrong password (color) */
|
||||||
|
static const int failonclear = 1;
|
||||||
|
+
|
||||||
|
+/*Set Blur radius*/
|
||||||
|
+static const int blurRadius=5;
|
||||||
|
\ No newline at end of file
|
||||||
|
diff --git a/slock.c b/slock.c
|
||||||
|
index 7c63f34..0f24cd7 100644
|
||||||
|
--- a/slock.c
|
||||||
|
+++ b/slock.c
|
||||||
|
@@ -372,7 +372,7 @@ main(int argc, char **argv) {
|
||||||
|
die("slock: setgid: %s\n", strerror(errno));
|
||||||
|
if (setuid(duid) < 0)
|
||||||
|
die("slock: setuid: %s\n", strerror(errno));
|
||||||
|
-
|
||||||
|
+
|
||||||
|
/*Create screenshot Image*/
|
||||||
|
Screen *scr = ScreenOfDisplay(dpy, DefaultScreen(dpy));
|
||||||
|
image = imlib_create_image(scr->width,scr->height);
|
||||||
|
@@ -381,6 +381,7 @@ main(int argc, char **argv) {
|
||||||
|
imlib_context_set_visual(DefaultVisual(dpy,0));
|
||||||
|
imlib_context_set_drawable(RootWindow(dpy,XScreenNumberOfScreen(scr)));
|
||||||
|
imlib_copy_drawable_to_image(0,0,0,scr->width,scr->height,0,0,1);
|
||||||
|
+ imlib_image_blur(blurRadius);
|
||||||
|
|
||||||
|
/* check for Xrandr support */
|
||||||
|
rr.active = XRRQueryExtension(dpy, &rr.evbase, &rr.errbase);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
|
|
||||||
|
From 069aabd7e30244befd4efe74c85d3468ed076c21 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lars Niesen <iah71niesen@gso-koeln.de>
|
||||||
|
Date: Wed, 29 Apr 2020 17:33:09 +0200
|
||||||
|
Subject: [PATCH 4/8] added Pixelation
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 3 ++-
|
||||||
|
slock.c | 42 ++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 44 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index fcc1b39..1c1aef3 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -12,4 +12,5 @@ static const char *colorname[NUMCOLS] = {
|
||||||
|
static const int failonclear = 1;
|
||||||
|
|
||||||
|
/*Set Blur radius*/
|
||||||
|
-static const int blurRadius=5;
|
||||||
|
\ No newline at end of file
|
||||||
|
+static const int blurRadius=0;
|
||||||
|
+static const int pixelSize=5;
|
||||||
|
diff --git a/slock.c b/slock.c
|
||||||
|
index 0f24cd7..33ca569 100644
|
||||||
|
--- a/slock.c
|
||||||
|
+++ b/slock.c
|
||||||
|
@@ -381,7 +381,49 @@ main(int argc, char **argv) {
|
||||||
|
imlib_context_set_visual(DefaultVisual(dpy,0));
|
||||||
|
imlib_context_set_drawable(RootWindow(dpy,XScreenNumberOfScreen(scr)));
|
||||||
|
imlib_copy_drawable_to_image(0,0,0,scr->width,scr->height,0,0,1);
|
||||||
|
+
|
||||||
|
+ /*Blur function*/
|
||||||
|
imlib_image_blur(blurRadius);
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ /*Pixelation*/
|
||||||
|
+ int width = scr->width;
|
||||||
|
+ int height = scr->height;
|
||||||
|
+
|
||||||
|
+ for(int y = 0; y < height; y += pixelSize)
|
||||||
|
+ {
|
||||||
|
+ for(int x = 0; x < width; x += pixelSize)
|
||||||
|
+ {
|
||||||
|
+ int red = 0;
|
||||||
|
+ int green = 0;
|
||||||
|
+ int blue = 0;
|
||||||
|
+
|
||||||
|
+ Imlib_Color pixel;
|
||||||
|
+ Imlib_Color* pp;
|
||||||
|
+ pp = &pixel;
|
||||||
|
+ for(int j = 0; j < pixelSize && j < height; j++)
|
||||||
|
+ {
|
||||||
|
+ for(int i = 0; i < pixelSize && i < width; i++)
|
||||||
|
+ {
|
||||||
|
+ imlib_image_query_pixel(x+i,y+j,pp);
|
||||||
|
+ red += pixel.red;
|
||||||
|
+ green += pixel.green;
|
||||||
|
+ blue += pixel.blue;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ red /= (pixelSize*pixelSize);
|
||||||
|
+ green /= (pixelSize*pixelSize);
|
||||||
|
+ blue /= (pixelSize*pixelSize);
|
||||||
|
+ printf("R/G/B: %i/%i/%i\n",red,green,blue);
|
||||||
|
+ imlib_context_set_color(red,green,blue,pixel.alpha);
|
||||||
|
+ imlib_image_fill_rectangle(x,y,pixelSize,pixelSize);
|
||||||
|
+ red = 0;
|
||||||
|
+ green = 0;
|
||||||
|
+ blue = 0;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+
|
||||||
|
|
||||||
|
/* check for Xrandr support */
|
||||||
|
rr.active = XRRQueryExtension(dpy, &rr.evbase, &rr.errbase);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
|
|
||||||
|
From 109bac015c1c7fbf8440fb42588fe7e0e9cb5e62 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lars Niesen <iah71niesen@gso-koeln.de>
|
||||||
|
Date: Wed, 29 Apr 2020 17:42:39 +0200
|
||||||
|
Subject: [PATCH 6/8] removed debug printf
|
||||||
|
|
||||||
|
---
|
||||||
|
slock.c | 1 -
|
||||||
|
1 file changed, 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/slock.c b/slock.c
|
||||||
|
index 33ca569..f54c459 100644
|
||||||
|
--- a/slock.c
|
||||||
|
+++ b/slock.c
|
||||||
|
@@ -414,7 +414,6 @@ main(int argc, char **argv) {
|
||||||
|
red /= (pixelSize*pixelSize);
|
||||||
|
green /= (pixelSize*pixelSize);
|
||||||
|
blue /= (pixelSize*pixelSize);
|
||||||
|
- printf("R/G/B: %i/%i/%i\n",red,green,blue);
|
||||||
|
imlib_context_set_color(red,green,blue,pixel.alpha);
|
||||||
|
imlib_image_fill_rectangle(x,y,pixelSize,pixelSize);
|
||||||
|
red = 0;
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
|
|
||||||
|
From a13a0f4ac86f82e4dff145b7ebd93e52d07492c9 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lars Niesen <iah71niesen@gso-koeln.de>
|
||||||
|
Date: Sun, 3 May 2020 18:03:38 +0200
|
||||||
|
Subject: [PATCH 7/8] Changed compilerflag to fast
|
||||||
|
|
||||||
|
---
|
||||||
|
config.mk | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/config.mk b/config.mk
|
||||||
|
index 987819e..d0c2f01 100644
|
||||||
|
--- a/config.mk
|
||||||
|
+++ b/config.mk
|
||||||
|
@@ -16,7 +16,7 @@ LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lImlib2
|
||||||
|
|
||||||
|
# flags
|
||||||
|
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H
|
||||||
|
-CFLAGS = -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
|
||||||
|
+CFLAGS = -std=c99 -pedantic -Wall -Ofast ${INCS} ${CPPFLAGS}
|
||||||
|
LDFLAGS = -s ${LIBS}
|
||||||
|
COMPATSRC = explicit_bzero.c
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
|
|
||||||
|
From 31a7001c4954606c066cc3df4318fafd6d216bcd Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lars Niesen <iah71niesen@gso-koeln.de>
|
||||||
|
Date: Mon, 4 May 2020 10:00:40 +0200
|
||||||
|
Subject: [PATCH 8/8] Added defines for BLUR/PIXELATION to remove from code by
|
||||||
|
compilation
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 11 ++++++++---
|
||||||
|
slock.c | 9 ++++++---
|
||||||
|
2 files changed, 14 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1c1aef3..5407953 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -11,6 +11,11 @@ static const char *colorname[NUMCOLS] = {
|
||||||
|
/* treat a cleared input like a wrong password (color) */
|
||||||
|
static const int failonclear = 1;
|
||||||
|
|
||||||
|
-/*Set Blur radius*/
|
||||||
|
-static const int blurRadius=0;
|
||||||
|
-static const int pixelSize=5;
|
||||||
|
+/*Enable blur*/
|
||||||
|
+#define BLUR
|
||||||
|
+/*Set blur radius*/
|
||||||
|
+static const int blurRadius=5;
|
||||||
|
+/*Enable Pixelation*/
|
||||||
|
+//#define PIXELATION
|
||||||
|
+/*Set pixelation radius*/
|
||||||
|
+static const int pixelSize=0;
|
||||||
|
diff --git a/slock.c b/slock.c
|
||||||
|
index f54c459..1a4d6e3 100644
|
||||||
|
--- a/slock.c
|
||||||
|
+++ b/slock.c
|
||||||
|
@@ -381,11 +381,14 @@ main(int argc, char **argv) {
|
||||||
|
imlib_context_set_visual(DefaultVisual(dpy,0));
|
||||||
|
imlib_context_set_drawable(RootWindow(dpy,XScreenNumberOfScreen(scr)));
|
||||||
|
imlib_copy_drawable_to_image(0,0,0,scr->width,scr->height,0,0,1);
|
||||||
|
-
|
||||||
|
+
|
||||||
|
+#ifdef BLUR
|
||||||
|
+
|
||||||
|
/*Blur function*/
|
||||||
|
imlib_image_blur(blurRadius);
|
||||||
|
+#endif // BLUR
|
||||||
|
|
||||||
|
-
|
||||||
|
+#ifdef PIXELATION
|
||||||
|
/*Pixelation*/
|
||||||
|
int width = scr->width;
|
||||||
|
int height = scr->height;
|
||||||
|
@@ -423,7 +426,7 @@ main(int argc, char **argv) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
-
|
||||||
|
+#endif
|
||||||
|
/* check for Xrandr support */
|
||||||
|
rr.active = XRRQueryExtension(dpy, &rr.evbase, &rr.errbase);
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
250
slock-1.4/patches/slock-message-20191002-b46028b.diff
Normal file
250
slock-1.4/patches/slock-message-20191002-b46028b.diff
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
From b46028b2797b886154258dcafe71c349cdc68b43 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Blair Drummond <blair.robert.drummond@gmail.com>
|
||||||
|
Date: Wed, 2 Oct 2019 14:59:00 -0400
|
||||||
|
Subject: [PATCH] Add a message command. Fixes old version's bugs.
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 9 ++++
|
||||||
|
config.mk | 2 +-
|
||||||
|
slock.1 | 7 +++
|
||||||
|
slock.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||||
|
4 files changed, 133 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 9855e21..c2a0ab2 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -10,3 +10,12 @@ static const char *colorname[NUMCOLS] = {
|
||||||
|
|
||||||
|
/* treat a cleared input like a wrong password (color) */
|
||||||
|
static const int failonclear = 1;
|
||||||
|
+
|
||||||
|
+/* default message */
|
||||||
|
+static const char * message = "Suckless: Software that sucks less.";
|
||||||
|
+
|
||||||
|
+/* text color */
|
||||||
|
+static const char * text_color = "#ffffff";
|
||||||
|
+
|
||||||
|
+/* text size (must be a valid size) */
|
||||||
|
+static const char * font_name = "6x10";
|
||||||
|
diff --git a/config.mk b/config.mk
|
||||||
|
index 74429ae..c4ccf66 100644
|
||||||
|
--- a/config.mk
|
||||||
|
+++ b/config.mk
|
||||||
|
@@ -12,7 +12,7 @@ X11LIB = /usr/X11R6/lib
|
||||||
|
|
||||||
|
# includes and libs
|
||||||
|
INCS = -I. -I/usr/include -I${X11INC}
|
||||||
|
-LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr
|
||||||
|
+LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr -lXinerama
|
||||||
|
|
||||||
|
# flags
|
||||||
|
CPPFLAGS = -DVERSION=\"${VERSION}\" -D_DEFAULT_SOURCE -DHAVE_SHADOW_H
|
||||||
|
diff --git a/slock.1 b/slock.1
|
||||||
|
index 82cdcd6..946165f 100644
|
||||||
|
--- a/slock.1
|
||||||
|
+++ b/slock.1
|
||||||
|
@@ -6,6 +6,8 @@
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Op Fl v
|
||||||
|
+.Op Fl f
|
||||||
|
+.Op Fl m Ar message
|
||||||
|
.Op Ar cmd Op Ar arg ...
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
.Nm
|
||||||
|
@@ -16,6 +18,11 @@ is executed after the screen has been locked.
|
||||||
|
.Bl -tag -width Ds
|
||||||
|
.It Fl v
|
||||||
|
Print version information to stdout and exit.
|
||||||
|
+.It Fl f
|
||||||
|
+List all valid X fonts and exit.
|
||||||
|
+.It Fl m Ar message
|
||||||
|
+Overrides default slock lock message.
|
||||||
|
+.TP
|
||||||
|
.El
|
||||||
|
.Sh SECURITY CONSIDERATIONS
|
||||||
|
To make sure a locked screen can not be bypassed by switching VTs
|
||||||
|
diff --git a/slock.c b/slock.c
|
||||||
|
index 5ae738c..610929b 100644
|
||||||
|
--- a/slock.c
|
||||||
|
+++ b/slock.c
|
||||||
|
@@ -15,6 +15,7 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
+#include <X11/extensions/Xinerama.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
@@ -24,6 +25,9 @@
|
||||||
|
|
||||||
|
char *argv0;
|
||||||
|
|
||||||
|
+/* global count to prevent repeated error messages */
|
||||||
|
+int count_error = 0;
|
||||||
|
+
|
||||||
|
enum {
|
||||||
|
INIT,
|
||||||
|
INPUT,
|
||||||
|
@@ -83,6 +87,98 @@ dontkillme(void)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
+static void
|
||||||
|
+writemessage(Display *dpy, Window win, int screen)
|
||||||
|
+{
|
||||||
|
+ int len, line_len, width, height, s_width, s_height, i, j, k, tab_replace, tab_size;
|
||||||
|
+ XGCValues gr_values;
|
||||||
|
+ XFontStruct *fontinfo;
|
||||||
|
+ XColor color, dummy;
|
||||||
|
+ XineramaScreenInfo *xsi;
|
||||||
|
+ GC gc;
|
||||||
|
+ fontinfo = XLoadQueryFont(dpy, font_name);
|
||||||
|
+
|
||||||
|
+ if (fontinfo == NULL) {
|
||||||
|
+ if (count_error == 0) {
|
||||||
|
+ fprintf(stderr, "slock: Unable to load font \"%s\"\n", font_name);
|
||||||
|
+ fprintf(stderr, "slock: Try listing fonts with 'slock -f'\n");
|
||||||
|
+ count_error++;
|
||||||
|
+ }
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ tab_size = 8 * XTextWidth(fontinfo, " ", 1);
|
||||||
|
+
|
||||||
|
+ XAllocNamedColor(dpy, DefaultColormap(dpy, screen),
|
||||||
|
+ text_color, &color, &dummy);
|
||||||
|
+
|
||||||
|
+ gr_values.font = fontinfo->fid;
|
||||||
|
+ gr_values.foreground = color.pixel;
|
||||||
|
+ gc=XCreateGC(dpy,win,GCFont+GCForeground, &gr_values);
|
||||||
|
+
|
||||||
|
+ /* To prevent "Uninitialized" warnings. */
|
||||||
|
+ xsi = NULL;
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ * Start formatting and drawing text
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+ len = strlen(message);
|
||||||
|
+
|
||||||
|
+ /* Max max line length (cut at '\n') */
|
||||||
|
+ line_len = 0;
|
||||||
|
+ k = 0;
|
||||||
|
+ for (i = j = 0; i < len; i++) {
|
||||||
|
+ if (message[i] == '\n') {
|
||||||
|
+ if (i - j > line_len)
|
||||||
|
+ line_len = i - j;
|
||||||
|
+ k++;
|
||||||
|
+ i++;
|
||||||
|
+ j = i;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ /* If there is only one line */
|
||||||
|
+ if (line_len == 0)
|
||||||
|
+ line_len = len;
|
||||||
|
+
|
||||||
|
+ if (XineramaIsActive(dpy)) {
|
||||||
|
+ xsi = XineramaQueryScreens(dpy, &i);
|
||||||
|
+ s_width = xsi[0].width;
|
||||||
|
+ s_height = xsi[0].height;
|
||||||
|
+ } else {
|
||||||
|
+ s_width = DisplayWidth(dpy, screen);
|
||||||
|
+ s_height = DisplayHeight(dpy, screen);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ height = s_height*3/7 - (k*20)/3;
|
||||||
|
+ width = (s_width - XTextWidth(fontinfo, message, line_len))/2;
|
||||||
|
+
|
||||||
|
+ /* Look for '\n' and print the text between them. */
|
||||||
|
+ for (i = j = k = 0; i <= len; i++) {
|
||||||
|
+ /* i == len is the special case for the last line */
|
||||||
|
+ if (i == len || message[i] == '\n') {
|
||||||
|
+ tab_replace = 0;
|
||||||
|
+ while (message[j] == '\t' && j < i) {
|
||||||
|
+ tab_replace++;
|
||||||
|
+ j++;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ XDrawString(dpy, win, gc, width + tab_size*tab_replace, height + 20*k, message + j, i - j);
|
||||||
|
+ while (i < len && message[i] == '\n') {
|
||||||
|
+ i++;
|
||||||
|
+ j = i;
|
||||||
|
+ k++;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* xsi should not be NULL anyway if Xinerama is active, but to be safe */
|
||||||
|
+ if (XineramaIsActive(dpy) && xsi != NULL)
|
||||||
|
+ XFree(xsi);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+
|
||||||
|
static const char *
|
||||||
|
gethash(void)
|
||||||
|
{
|
||||||
|
@@ -194,6 +290,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
|
||||||
|
locks[screen]->win,
|
||||||
|
locks[screen]->colors[color]);
|
||||||
|
XClearWindow(dpy, locks[screen]->win);
|
||||||
|
+ writemessage(dpy, locks[screen]->win, screen);
|
||||||
|
}
|
||||||
|
oldc = color;
|
||||||
|
}
|
||||||
|
@@ -300,7 +397,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
- die("usage: slock [-v] [cmd [arg ...]]\n");
|
||||||
|
+ die("usage: slock [-v] [-f] [-m message] [cmd [arg ...]]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
@@ -313,12 +410,25 @@ main(int argc, char **argv) {
|
||||||
|
gid_t dgid;
|
||||||
|
const char *hash;
|
||||||
|
Display *dpy;
|
||||||
|
- int s, nlocks, nscreens;
|
||||||
|
+ int i, s, nlocks, nscreens;
|
||||||
|
+ int count_fonts;
|
||||||
|
+ char **font_names;
|
||||||
|
|
||||||
|
ARGBEGIN {
|
||||||
|
case 'v':
|
||||||
|
fprintf(stderr, "slock-"VERSION"\n");
|
||||||
|
return 0;
|
||||||
|
+ case 'm':
|
||||||
|
+ message = EARGF(usage());
|
||||||
|
+ break;
|
||||||
|
+ case 'f':
|
||||||
|
+ if (!(dpy = XOpenDisplay(NULL)))
|
||||||
|
+ die("slock: cannot open display\n");
|
||||||
|
+ font_names = XListFonts(dpy, "*", 10000 /* list 10000 fonts*/, &count_fonts);
|
||||||
|
+ for (i=0; i<count_fonts; i++) {
|
||||||
|
+ fprintf(stderr, "%s\n", *(font_names+i));
|
||||||
|
+ }
|
||||||
|
+ return 0;
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
} ARGEND
|
||||||
|
@@ -363,10 +473,12 @@ main(int argc, char **argv) {
|
||||||
|
if (!(locks = calloc(nscreens, sizeof(struct lock *))))
|
||||||
|
die("slock: out of memory\n");
|
||||||
|
for (nlocks = 0, s = 0; s < nscreens; s++) {
|
||||||
|
- if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL)
|
||||||
|
+ if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL) {
|
||||||
|
+ writemessage(dpy, locks[s]->win, s);
|
||||||
|
nlocks++;
|
||||||
|
- else
|
||||||
|
+ } else {
|
||||||
|
break;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
XSync(dpy, 0);
|
||||||
|
|
||||||
|
--
|
||||||
|
2.20.1
|
||||||
|
|
66
slock-1.4/patches/slock-quickcancel-1.4.diff
Normal file
66
slock-1.4/patches/slock-quickcancel-1.4.diff
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
From e37f8981efe54bc620cb2f2280832cdab3959a32 Mon Sep 17 00:00:00 2001
|
||||||
|
From: aleks <aleks.stier@icloud.com>
|
||||||
|
Date: Thu, 10 Oct 2019 17:35:27 +0200
|
||||||
|
Subject: [PATCH] Apply quickcancel
|
||||||
|
|
||||||
|
Cancel slock by moving the mouse within a certain time-period after
|
||||||
|
slock started. The time-period can be defined in seconds with the
|
||||||
|
setting *timetocancel* in the config.h. This is useful if you forgot to
|
||||||
|
disable `xautolock` during an activity that requires no input (e.g.
|
||||||
|
reading text, watching video).
|
||||||
|
---
|
||||||
|
config.def.h | 3 +++
|
||||||
|
slock.c | 5 +++++
|
||||||
|
2 files changed, 8 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 9855e21..e0bf95a 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -10,3 +10,6 @@ static const char *colorname[NUMCOLS] = {
|
||||||
|
|
||||||
|
/* treat a cleared input like a wrong password (color) */
|
||||||
|
static const int failonclear = 1;
|
||||||
|
+
|
||||||
|
+/* time in seconds to cancel lock with mouse movement */
|
||||||
|
+static const int timetocancel = 4;
|
||||||
|
diff --git a/slock.c b/slock.c
|
||||||
|
index d2f0886..f7462ee 100644
|
||||||
|
--- a/slock.c
|
||||||
|
+++ b/slock.c
|
||||||
|
@@ -13,6 +13,7 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
+#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
@@ -24,6 +25,8 @@
|
||||||
|
|
||||||
|
char *argv0;
|
||||||
|
|
||||||
|
+static time_t locktime;
|
||||||
|
+
|
||||||
|
enum {
|
||||||
|
INIT,
|
||||||
|
INPUT,
|
||||||
|
@@ -141,6 +144,7 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
|
||||||
|
oldc = INIT;
|
||||||
|
|
||||||
|
while (running && !XNextEvent(dpy, &ev)) {
|
||||||
|
+ running = !((time(NULL) - locktime < timetocancel) && (ev.type == MotionNotify));
|
||||||
|
if (ev.type == KeyPress) {
|
||||||
|
explicit_bzero(&buf, sizeof(buf));
|
||||||
|
num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0);
|
||||||
|
@@ -268,6 +272,7 @@ lockscreen(Display *dpy, struct xrandr *rr, int screen)
|
||||||
|
XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask);
|
||||||
|
|
||||||
|
XSelectInput(dpy, lock->root, SubstructureNotifyMask);
|
||||||
|
+ locktime = time(NULL);
|
||||||
|
return lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.23.0
|
||||||
|
|
46
slock-1.4/slock.1
Normal file
46
slock-1.4/slock.1
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
.Dd 2016-08-23
|
||||||
|
.Dt SLOCK 1
|
||||||
|
.Sh NAME
|
||||||
|
.Nm slock
|
||||||
|
.Nd simple X screen locker
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Op Fl v
|
||||||
|
.Op Fl f
|
||||||
|
.Op Fl m Ar message
|
||||||
|
.Op Ar cmd Op Ar arg ...
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
.Nm
|
||||||
|
is a simple X screen locker. If provided,
|
||||||
|
.Ar cmd Op Ar arg ...
|
||||||
|
is executed after the screen has been locked.
|
||||||
|
.Sh OPTIONS
|
||||||
|
.Bl -tag -width Ds
|
||||||
|
.It Fl v
|
||||||
|
Print version information to stdout and exit.
|
||||||
|
.It Fl f
|
||||||
|
List all valid X fonts and exit.
|
||||||
|
.It Fl m Ar message
|
||||||
|
Overrides default slock lock message.
|
||||||
|
.TP
|
||||||
|
.El
|
||||||
|
.Sh SECURITY CONSIDERATIONS
|
||||||
|
To make sure a locked screen can not be bypassed by switching VTs
|
||||||
|
or killing the X server with Ctrl+Alt+Backspace, it is recommended
|
||||||
|
to disable both in
|
||||||
|
.Xr xorg.conf 5
|
||||||
|
for maximum security:
|
||||||
|
.Bd -literal -offset left
|
||||||
|
Section "ServerFlags"
|
||||||
|
Option "DontVTSwitch" "True"
|
||||||
|
Option "DontZap" "True"
|
||||||
|
EndSection
|
||||||
|
.Ed
|
||||||
|
.Sh EXAMPLES
|
||||||
|
$
|
||||||
|
.Nm
|
||||||
|
/usr/sbin/s2ram
|
||||||
|
.Sh CUSTOMIZATION
|
||||||
|
.Nm
|
||||||
|
can be customized by creating a custom config.h from config.def.h and
|
||||||
|
(re)compiling the source code. This keeps it fast, secure and simple.
|
576
slock-1.4/slock.c
Normal file
576
slock-1.4/slock.c
Normal file
@ -0,0 +1,576 @@
|
|||||||
|
/* See LICENSE file for license details. */
|
||||||
|
#define _XOPEN_SOURCE 500
|
||||||
|
#if HAVE_SHADOW_H
|
||||||
|
#include <shadow.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <grp.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
#include <X11/keysym.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#include <Imlib2.h>
|
||||||
|
|
||||||
|
#include "arg.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
char *argv0;
|
||||||
|
|
||||||
|
static time_t locktime;
|
||||||
|
|
||||||
|
/* global count to prevent repeated error messages */
|
||||||
|
int count_error = 0;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
INIT,
|
||||||
|
INPUT,
|
||||||
|
FAILED,
|
||||||
|
NUMCOLS
|
||||||
|
};
|
||||||
|
|
||||||
|
struct lock {
|
||||||
|
int screen;
|
||||||
|
Window root, win;
|
||||||
|
Pixmap pmap;
|
||||||
|
Pixmap bgmap;
|
||||||
|
unsigned long colors[NUMCOLS];
|
||||||
|
};
|
||||||
|
|
||||||
|
struct xrandr {
|
||||||
|
int active;
|
||||||
|
int evbase;
|
||||||
|
int errbase;
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
Imlib_Image image;
|
||||||
|
|
||||||
|
static void
|
||||||
|
die(const char *errstr, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, errstr);
|
||||||
|
vfprintf(stderr, errstr, ap);
|
||||||
|
va_end(ap);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <linux/oom.h>
|
||||||
|
|
||||||
|
static void
|
||||||
|
dontkillme(void)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
const char oomfile[] = "/proc/self/oom_score_adj";
|
||||||
|
|
||||||
|
if (!(f = fopen(oomfile, "w"))) {
|
||||||
|
if (errno == ENOENT)
|
||||||
|
return;
|
||||||
|
die("slock: fopen %s: %s\n", oomfile, strerror(errno));
|
||||||
|
}
|
||||||
|
fprintf(f, "%d", OOM_SCORE_ADJ_MIN);
|
||||||
|
if (fclose(f)) {
|
||||||
|
if (errno == EACCES)
|
||||||
|
die("slock: unable to disable OOM killer. "
|
||||||
|
"Make sure to suid or sgid slock.\n");
|
||||||
|
else
|
||||||
|
die("slock: fclose %s: %s\n", oomfile, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void
|
||||||
|
writemessage(Display *dpy, Window win, int screen)
|
||||||
|
{
|
||||||
|
int len, line_len, width, height, s_width, s_height, i, j, k, tab_replace, tab_size;
|
||||||
|
XGCValues gr_values;
|
||||||
|
XFontStruct *fontinfo;
|
||||||
|
XColor color, dummy;
|
||||||
|
XineramaScreenInfo *xsi;
|
||||||
|
GC gc;
|
||||||
|
fontinfo = XLoadQueryFont(dpy, font_name);
|
||||||
|
|
||||||
|
if (fontinfo == NULL) {
|
||||||
|
if (count_error == 0) {
|
||||||
|
fprintf(stderr, "slock: Unable to load font \"%s\"\n", font_name);
|
||||||
|
fprintf(stderr, "slock: Try listing fonts with 'slock -f'\n");
|
||||||
|
count_error++;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tab_size = 8 * XTextWidth(fontinfo, " ", 1);
|
||||||
|
|
||||||
|
XAllocNamedColor(dpy, DefaultColormap(dpy, screen),
|
||||||
|
text_color, &color, &dummy);
|
||||||
|
|
||||||
|
gr_values.font = fontinfo->fid;
|
||||||
|
gr_values.foreground = color.pixel;
|
||||||
|
gc=XCreateGC(dpy,win,GCFont+GCForeground, &gr_values);
|
||||||
|
|
||||||
|
/* To prevent "Uninitialized" warnings. */
|
||||||
|
xsi = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Start formatting and drawing text
|
||||||
|
*/
|
||||||
|
|
||||||
|
len = strlen(message);
|
||||||
|
|
||||||
|
/* Max max line length (cut at '\n') */
|
||||||
|
line_len = 0;
|
||||||
|
k = 0;
|
||||||
|
for (i = j = 0; i < len; i++) {
|
||||||
|
if (message[i] == '\n') {
|
||||||
|
if (i - j > line_len)
|
||||||
|
line_len = i - j;
|
||||||
|
k++;
|
||||||
|
i++;
|
||||||
|
j = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* If there is only one line */
|
||||||
|
if (line_len == 0)
|
||||||
|
line_len = len;
|
||||||
|
|
||||||
|
if (XineramaIsActive(dpy)) {
|
||||||
|
xsi = XineramaQueryScreens(dpy, &i);
|
||||||
|
s_width = xsi[0].width;
|
||||||
|
s_height = xsi[0].height;
|
||||||
|
} else {
|
||||||
|
s_width = DisplayWidth(dpy, screen);
|
||||||
|
s_height = DisplayHeight(dpy, screen);
|
||||||
|
}
|
||||||
|
|
||||||
|
height = s_height*3/7 - (k*20)/3;
|
||||||
|
width = (s_width - XTextWidth(fontinfo, message, line_len))/2;
|
||||||
|
|
||||||
|
/* Look for '\n' and print the text between them. */
|
||||||
|
for (i = j = k = 0; i <= len; i++) {
|
||||||
|
/* i == len is the special case for the last line */
|
||||||
|
if (i == len || message[i] == '\n') {
|
||||||
|
tab_replace = 0;
|
||||||
|
while (message[j] == '\t' && j < i) {
|
||||||
|
tab_replace++;
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
XDrawString(dpy, win, gc, width + tab_size*tab_replace, height + 20*k, message + j, i - j);
|
||||||
|
while (i < len && message[i] == '\n') {
|
||||||
|
i++;
|
||||||
|
j = i;
|
||||||
|
k++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* xsi should not be NULL anyway if Xinerama is active, but to be safe */
|
||||||
|
if (XineramaIsActive(dpy) && xsi != NULL)
|
||||||
|
XFree(xsi);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static const char *
|
||||||
|
gethash(void)
|
||||||
|
{
|
||||||
|
const char *hash;
|
||||||
|
struct passwd *pw;
|
||||||
|
|
||||||
|
/* Check if the current user has a password entry */
|
||||||
|
errno = 0;
|
||||||
|
if (!(pw = getpwuid(getuid()))) {
|
||||||
|
if (errno)
|
||||||
|
die("slock: getpwuid: %s\n", strerror(errno));
|
||||||
|
else
|
||||||
|
die("slock: cannot retrieve password entry\n");
|
||||||
|
}
|
||||||
|
hash = pw->pw_passwd;
|
||||||
|
|
||||||
|
#if HAVE_SHADOW_H
|
||||||
|
if (!strcmp(hash, "x")) {
|
||||||
|
struct spwd *sp;
|
||||||
|
if (!(sp = getspnam(pw->pw_name)))
|
||||||
|
die("slock: getspnam: cannot retrieve shadow entry. "
|
||||||
|
"Make sure to suid or sgid slock.\n");
|
||||||
|
hash = sp->sp_pwdp;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (!strcmp(hash, "*")) {
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
if (!(pw = getpwuid_shadow(getuid())))
|
||||||
|
die("slock: getpwnam_shadow: cannot retrieve shadow entry. "
|
||||||
|
"Make sure to suid or sgid slock.\n");
|
||||||
|
hash = pw->pw_passwd;
|
||||||
|
#else
|
||||||
|
die("slock: getpwuid: cannot retrieve shadow entry. "
|
||||||
|
"Make sure to suid or sgid slock.\n");
|
||||||
|
#endif /* __OpenBSD__ */
|
||||||
|
}
|
||||||
|
#endif /* HAVE_SHADOW_H */
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
|
||||||
|
const char *hash)
|
||||||
|
{
|
||||||
|
XRRScreenChangeNotifyEvent *rre;
|
||||||
|
char buf[32], passwd[256], *inputhash;
|
||||||
|
int num, screen, running, failure, oldc;
|
||||||
|
unsigned int len, color;
|
||||||
|
KeySym ksym;
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
|
len = 0;
|
||||||
|
running = 1;
|
||||||
|
failure = 0;
|
||||||
|
oldc = INIT;
|
||||||
|
|
||||||
|
while (running && !XNextEvent(dpy, &ev)) {
|
||||||
|
running = !((time(NULL) - locktime < timetocancel) && (ev.type == MotionNotify));
|
||||||
|
if (ev.type == KeyPress) {
|
||||||
|
explicit_bzero(&buf, sizeof(buf));
|
||||||
|
num = XLookupString(&ev.xkey, buf, sizeof(buf), &ksym, 0);
|
||||||
|
if (IsKeypadKey(ksym)) {
|
||||||
|
if (ksym == XK_KP_Enter)
|
||||||
|
ksym = XK_Return;
|
||||||
|
else if (ksym >= XK_KP_0 && ksym <= XK_KP_9)
|
||||||
|
ksym = (ksym - XK_KP_0) + XK_0;
|
||||||
|
}
|
||||||
|
if (IsFunctionKey(ksym) ||
|
||||||
|
IsKeypadKey(ksym) ||
|
||||||
|
IsMiscFunctionKey(ksym) ||
|
||||||
|
IsPFKey(ksym) ||
|
||||||
|
IsPrivateKeypadKey(ksym))
|
||||||
|
continue;
|
||||||
|
switch (ksym) {
|
||||||
|
case XK_Return:
|
||||||
|
passwd[len] = '\0';
|
||||||
|
errno = 0;
|
||||||
|
if (!(inputhash = crypt(passwd, hash)))
|
||||||
|
fprintf(stderr, "slock: crypt: %s\n", strerror(errno));
|
||||||
|
else
|
||||||
|
running = !!strcmp(inputhash, hash);
|
||||||
|
if (running) {
|
||||||
|
XBell(dpy, 100);
|
||||||
|
failure = 1;
|
||||||
|
}
|
||||||
|
explicit_bzero(&passwd, sizeof(passwd));
|
||||||
|
len = 0;
|
||||||
|
break;
|
||||||
|
case XK_Escape:
|
||||||
|
explicit_bzero(&passwd, sizeof(passwd));
|
||||||
|
len = 0;
|
||||||
|
break;
|
||||||
|
case XK_BackSpace:
|
||||||
|
if (len)
|
||||||
|
passwd[len--] = '\0';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (num && !iscntrl((int)buf[0]) &&
|
||||||
|
(len + num < sizeof(passwd))) {
|
||||||
|
memcpy(passwd + len, buf, num);
|
||||||
|
len += num;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
color = len ? INPUT : ((failure || failonclear) ? FAILED : INIT);
|
||||||
|
if (running && oldc != color) {
|
||||||
|
for (screen = 0; screen < nscreens; screen++) {
|
||||||
|
if(locks[screen]->bgmap)
|
||||||
|
XSetWindowBackgroundPixmap(dpy, locks[screen]->win, locks[screen]->bgmap);
|
||||||
|
else
|
||||||
|
XSetWindowBackground(dpy, locks[screen]->win, locks[screen]->colors[0]);
|
||||||
|
XClearWindow(dpy, locks[screen]->win);
|
||||||
|
writemessage(dpy, locks[screen]->win, screen);
|
||||||
|
}
|
||||||
|
oldc = color;
|
||||||
|
}
|
||||||
|
} else if (rr->active && ev.type == rr->evbase + RRScreenChangeNotify) {
|
||||||
|
rre = (XRRScreenChangeNotifyEvent*)&ev;
|
||||||
|
for (screen = 0; screen < nscreens; screen++) {
|
||||||
|
if (locks[screen]->win == rre->window) {
|
||||||
|
XResizeWindow(dpy, locks[screen]->win,
|
||||||
|
rre->width, rre->height);
|
||||||
|
XClearWindow(dpy, locks[screen]->win);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else for (screen = 0; screen < nscreens; screen++)
|
||||||
|
XRaiseWindow(dpy, locks[screen]->win);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct lock *
|
||||||
|
lockscreen(Display *dpy, struct xrandr *rr, int screen)
|
||||||
|
{
|
||||||
|
char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
int i, ptgrab, kbgrab;
|
||||||
|
struct lock *lock;
|
||||||
|
XColor color, dummy;
|
||||||
|
XSetWindowAttributes wa;
|
||||||
|
Cursor invisible;
|
||||||
|
|
||||||
|
if (dpy == NULL || screen < 0 || !(lock = malloc(sizeof(struct lock))))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
lock->screen = screen;
|
||||||
|
lock->root = RootWindow(dpy, lock->screen);
|
||||||
|
|
||||||
|
if(image)
|
||||||
|
{
|
||||||
|
lock->bgmap = XCreatePixmap(dpy, lock->root, DisplayWidth(dpy, lock->screen), DisplayHeight(dpy, lock->screen), DefaultDepth(dpy, lock->screen));
|
||||||
|
imlib_context_set_image(image);
|
||||||
|
imlib_context_set_display(dpy);
|
||||||
|
imlib_context_set_visual(DefaultVisual(dpy, lock->screen));
|
||||||
|
imlib_context_set_colormap(DefaultColormap(dpy, lock->screen));
|
||||||
|
imlib_context_set_drawable(lock->bgmap);
|
||||||
|
imlib_render_image_on_drawable(0, 0);
|
||||||
|
imlib_free_image();
|
||||||
|
}
|
||||||
|
for (i = 0; i < NUMCOLS; i++) {
|
||||||
|
XAllocNamedColor(dpy, DefaultColormap(dpy, lock->screen),
|
||||||
|
colorname[i], &color, &dummy);
|
||||||
|
lock->colors[i] = color.pixel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* init */
|
||||||
|
wa.override_redirect = 1;
|
||||||
|
wa.background_pixel = lock->colors[INIT];
|
||||||
|
lock->win = XCreateWindow(dpy, lock->root, 0, 0,
|
||||||
|
DisplayWidth(dpy, lock->screen),
|
||||||
|
DisplayHeight(dpy, lock->screen),
|
||||||
|
0, DefaultDepth(dpy, lock->screen),
|
||||||
|
CopyFromParent,
|
||||||
|
DefaultVisual(dpy, lock->screen),
|
||||||
|
CWOverrideRedirect | CWBackPixel, &wa);
|
||||||
|
if(lock->bgmap)
|
||||||
|
XSetWindowBackgroundPixmap(dpy, lock->win, lock->bgmap);
|
||||||
|
lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8);
|
||||||
|
invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap,
|
||||||
|
&color, &color, 0, 0);
|
||||||
|
XDefineCursor(dpy, lock->win, invisible);
|
||||||
|
|
||||||
|
/* Try to grab mouse pointer *and* keyboard for 600ms, else fail the lock */
|
||||||
|
for (i = 0, ptgrab = kbgrab = -1; i < 6; i++) {
|
||||||
|
if (ptgrab != GrabSuccess) {
|
||||||
|
ptgrab = XGrabPointer(dpy, lock->root, False,
|
||||||
|
ButtonPressMask | ButtonReleaseMask |
|
||||||
|
PointerMotionMask, GrabModeAsync,
|
||||||
|
GrabModeAsync, None, invisible, CurrentTime);
|
||||||
|
}
|
||||||
|
if (kbgrab != GrabSuccess) {
|
||||||
|
kbgrab = XGrabKeyboard(dpy, lock->root, True,
|
||||||
|
GrabModeAsync, GrabModeAsync, CurrentTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* input is grabbed: we can lock the screen */
|
||||||
|
if (ptgrab == GrabSuccess && kbgrab == GrabSuccess) {
|
||||||
|
XMapRaised(dpy, lock->win);
|
||||||
|
if (rr->active)
|
||||||
|
XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask);
|
||||||
|
|
||||||
|
XSelectInput(dpy, lock->root, SubstructureNotifyMask);
|
||||||
|
locktime = time(NULL);
|
||||||
|
return lock;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* retry on AlreadyGrabbed but fail on other errors */
|
||||||
|
if ((ptgrab != AlreadyGrabbed && ptgrab != GrabSuccess) ||
|
||||||
|
(kbgrab != AlreadyGrabbed && kbgrab != GrabSuccess))
|
||||||
|
break;
|
||||||
|
|
||||||
|
usleep(100000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* we couldn't grab all input: fail out */
|
||||||
|
if (ptgrab != GrabSuccess)
|
||||||
|
fprintf(stderr, "slock: unable to grab mouse pointer for screen %d\n",
|
||||||
|
screen);
|
||||||
|
if (kbgrab != GrabSuccess)
|
||||||
|
fprintf(stderr, "slock: unable to grab keyboard for screen %d\n",
|
||||||
|
screen);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
die("usage: slock [-v] [-f] [-m message] [cmd [arg ...]]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv) {
|
||||||
|
struct xrandr rr;
|
||||||
|
struct lock **locks;
|
||||||
|
struct passwd *pwd;
|
||||||
|
struct group *grp;
|
||||||
|
uid_t duid;
|
||||||
|
gid_t dgid;
|
||||||
|
const char *hash;
|
||||||
|
Display *dpy;
|
||||||
|
int i, s, nlocks, nscreens;
|
||||||
|
int count_fonts;
|
||||||
|
char **font_names;
|
||||||
|
|
||||||
|
ARGBEGIN {
|
||||||
|
case 'v':
|
||||||
|
fprintf(stderr, "slock-"VERSION"\n");
|
||||||
|
return 0;
|
||||||
|
case 'm':
|
||||||
|
message = EARGF(usage());
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
|
die("slock: cannot open display\n");
|
||||||
|
font_names = XListFonts(dpy, "*", 10000 /* list 10000 fonts*/, &count_fonts);
|
||||||
|
for (i=0; i<count_fonts; i++) {
|
||||||
|
fprintf(stderr, "%s\n", *(font_names+i));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
} ARGEND
|
||||||
|
|
||||||
|
/* validate drop-user and -group */
|
||||||
|
errno = 0;
|
||||||
|
if (!(pwd = getpwnam(user)))
|
||||||
|
die("slock: getpwnam %s: %s\n", user,
|
||||||
|
errno ? strerror(errno) : "user entry not found");
|
||||||
|
duid = pwd->pw_uid;
|
||||||
|
errno = 0;
|
||||||
|
if (!(grp = getgrnam(group)))
|
||||||
|
die("slock: getgrnam %s: %s\n", group,
|
||||||
|
errno ? strerror(errno) : "group entry not found");
|
||||||
|
dgid = grp->gr_gid;
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
dontkillme();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
hash = gethash();
|
||||||
|
errno = 0;
|
||||||
|
if (!crypt("", hash))
|
||||||
|
die("slock: crypt: %s\n", strerror(errno));
|
||||||
|
|
||||||
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
|
die("slock: cannot open display\n");
|
||||||
|
|
||||||
|
/* drop privileges */
|
||||||
|
if (setgroups(0, NULL) < 0)
|
||||||
|
die("slock: setgroups: %s\n", strerror(errno));
|
||||||
|
if (setgid(dgid) < 0)
|
||||||
|
die("slock: setgid: %s\n", strerror(errno));
|
||||||
|
if (setuid(duid) < 0)
|
||||||
|
die("slock: setuid: %s\n", strerror(errno));
|
||||||
|
|
||||||
|
/*Create screenshot Image*/
|
||||||
|
Screen *scr = ScreenOfDisplay(dpy, DefaultScreen(dpy));
|
||||||
|
image = imlib_create_image(scr->width,scr->height);
|
||||||
|
imlib_context_set_image(image);
|
||||||
|
imlib_context_set_display(dpy);
|
||||||
|
imlib_context_set_visual(DefaultVisual(dpy,0));
|
||||||
|
imlib_context_set_drawable(RootWindow(dpy,XScreenNumberOfScreen(scr)));
|
||||||
|
imlib_copy_drawable_to_image(0,0,0,scr->width,scr->height,0,0,1);
|
||||||
|
|
||||||
|
#ifdef BLUR
|
||||||
|
|
||||||
|
/*Blur function*/
|
||||||
|
imlib_image_blur(blurRadius);
|
||||||
|
#endif // BLUR
|
||||||
|
|
||||||
|
#ifdef PIXELATION
|
||||||
|
/*Pixelation*/
|
||||||
|
int width = scr->width;
|
||||||
|
int height = scr->height;
|
||||||
|
|
||||||
|
for(int y = 0; y < height; y += pixelSize)
|
||||||
|
{
|
||||||
|
for(int x = 0; x < width; x += pixelSize)
|
||||||
|
{
|
||||||
|
int red = 0;
|
||||||
|
int green = 0;
|
||||||
|
int blue = 0;
|
||||||
|
|
||||||
|
Imlib_Color pixel;
|
||||||
|
Imlib_Color* pp;
|
||||||
|
pp = &pixel;
|
||||||
|
for(int j = 0; j < pixelSize && j < height; j++)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < pixelSize && i < width; i++)
|
||||||
|
{
|
||||||
|
imlib_image_query_pixel(x+i,y+j,pp);
|
||||||
|
red += pixel.red;
|
||||||
|
green += pixel.green;
|
||||||
|
blue += pixel.blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
red /= (pixelSize*pixelSize);
|
||||||
|
green /= (pixelSize*pixelSize);
|
||||||
|
blue /= (pixelSize*pixelSize);
|
||||||
|
imlib_context_set_color(red,green,blue,pixel.alpha);
|
||||||
|
imlib_image_fill_rectangle(x,y,pixelSize,pixelSize);
|
||||||
|
red = 0;
|
||||||
|
green = 0;
|
||||||
|
blue = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
/* check for Xrandr support */
|
||||||
|
rr.active = XRRQueryExtension(dpy, &rr.evbase, &rr.errbase);
|
||||||
|
|
||||||
|
/* get number of screens in display "dpy" and blank them */
|
||||||
|
nscreens = ScreenCount(dpy);
|
||||||
|
if (!(locks = calloc(nscreens, sizeof(struct lock *))))
|
||||||
|
die("slock: out of memory\n");
|
||||||
|
for (nlocks = 0, s = 0; s < nscreens; s++) {
|
||||||
|
if ((locks[s] = lockscreen(dpy, &rr, s)) != NULL) {
|
||||||
|
writemessage(dpy, locks[s]->win, s);
|
||||||
|
nlocks++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XSync(dpy, 0);
|
||||||
|
|
||||||
|
/* did we manage to lock everything? */
|
||||||
|
if (nlocks != nscreens)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* run post-lock command */
|
||||||
|
if (argc > 0) {
|
||||||
|
switch (fork()) {
|
||||||
|
case -1:
|
||||||
|
die("slock: fork failed: %s\n", strerror(errno));
|
||||||
|
case 0:
|
||||||
|
if (close(ConnectionNumber(dpy)) < 0)
|
||||||
|
die("slock: close: %s\n", strerror(errno));
|
||||||
|
execvp(argv[0], argv);
|
||||||
|
fprintf(stderr, "slock: execvp %s: %s\n", argv[0], strerror(errno));
|
||||||
|
_exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* everything is now blank. Wait for the correct password */
|
||||||
|
readpw(dpy, &rr, locks, nscreens, hash);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
2
slock-1.4/util.h
Normal file
2
slock-1.4/util.h
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
#undef explicit_bzero
|
||||||
|
void explicit_bzero(void *, size_t);
|
@ -1,485 +0,0 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* appearance
|
|
||||||
*
|
|
||||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
|
||||||
*/
|
|
||||||
static char *font = "MesloLGS NF:pixelsize=15:antialias=true:autohint=true";
|
|
||||||
static int borderpx = 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* What program is execed by st depends of these precedence rules:
|
|
||||||
* 1: program passed with -e
|
|
||||||
* 2: scroll and/or utmp
|
|
||||||
* 3: SHELL environment variable
|
|
||||||
* 4: value of shell in /etc/passwd
|
|
||||||
* 5: value of shell in config.h
|
|
||||||
*/
|
|
||||||
static char *shell = "/bin/sh";
|
|
||||||
char *utmp = NULL;
|
|
||||||
/* scroll program: to enable use a string like "scroll" */
|
|
||||||
char *scroll = NULL;
|
|
||||||
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
|
|
||||||
|
|
||||||
/* identification sequence returned in DA and DECID */
|
|
||||||
char *vtiden = "\033[?6c";
|
|
||||||
|
|
||||||
/* Kerning / character bounding-box multipliers */
|
|
||||||
static float cwscale = 1.0;
|
|
||||||
static float chscale = 1.0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* word delimiter string
|
|
||||||
*
|
|
||||||
* More advanced example: L" `'\"()[]{}"
|
|
||||||
*/
|
|
||||||
wchar_t *worddelimiters = L" ";
|
|
||||||
|
|
||||||
/* selection timeouts (in milliseconds) */
|
|
||||||
static unsigned int doubleclicktimeout = 300;
|
|
||||||
static unsigned int tripleclicktimeout = 600;
|
|
||||||
|
|
||||||
/* alt screens */
|
|
||||||
int allowaltscreen = 1;
|
|
||||||
|
|
||||||
/* allow certain non-interactive (insecure) window operations such as:
|
|
||||||
setting the clipboard text */
|
|
||||||
int allowwindowops = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* draw latency range in ms - from new content/keypress/etc until drawing.
|
|
||||||
* within this range, st draws when content stops arriving (idle). mostly it's
|
|
||||||
* near minlatency, but it waits longer for slow updates to avoid partial draw.
|
|
||||||
* low minlatency will tear/flicker more, as it can "detect" idle too early.
|
|
||||||
*/
|
|
||||||
static double minlatency = 8;
|
|
||||||
static double maxlatency = 33;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
|
||||||
* attribute.
|
|
||||||
*/
|
|
||||||
static unsigned int blinktimeout = 800;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* thickness of underline and bar cursors
|
|
||||||
*/
|
|
||||||
static unsigned int cursorthickness = 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* bell volume. It must be a value between -100 and 100. Use 0 for disabling
|
|
||||||
* it
|
|
||||||
*/
|
|
||||||
static int bellvolume = 0;
|
|
||||||
|
|
||||||
/* default TERM value */
|
|
||||||
char *termname = "st-256color";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* spaces per tab
|
|
||||||
*
|
|
||||||
* When you are changing this value, don't forget to adapt the »it« value in
|
|
||||||
* the st.info and appropriately install the st.info in the environment where
|
|
||||||
* you use this st version.
|
|
||||||
*
|
|
||||||
* it#$tabspaces,
|
|
||||||
*
|
|
||||||
* Secondly make sure your kernel is not expanding tabs. When running `stty
|
|
||||||
* -a` »tab0« should appear. You can tell the terminal to not expand tabs by
|
|
||||||
* running following command:
|
|
||||||
*
|
|
||||||
* stty tabs
|
|
||||||
*/
|
|
||||||
unsigned int tabspaces = 8;
|
|
||||||
|
|
||||||
/* bg opacity */
|
|
||||||
float alpha = 0.95;
|
|
||||||
|
|
||||||
/* Terminal colors (16 first used in escape sequence) */
|
|
||||||
static const char *colorname[] = {
|
|
||||||
/* 8 normal colors */
|
|
||||||
"#3b4252", /* black */
|
|
||||||
"#bf616a", /* red */
|
|
||||||
"#a3be8c", /* green */
|
|
||||||
"#ebcb8b", /* yellow */
|
|
||||||
"#81a1c1", /* blue */
|
|
||||||
"#b48ead", /* magenta */
|
|
||||||
"#88c0d0", /* cyan */
|
|
||||||
"#e5e9f0", /* white */
|
|
||||||
|
|
||||||
/* 8 bright colors */
|
|
||||||
"#4c566a", /* black */
|
|
||||||
"#bf616a", /* red */
|
|
||||||
"#a3be8c", /* green */
|
|
||||||
"#ebcb8b", /* yellow */
|
|
||||||
"#81a1c1", /* blue */
|
|
||||||
"#b48ead", /* magenta */
|
|
||||||
"#8fbcbb", /* cyan */
|
|
||||||
"#eceff4", /* white */
|
|
||||||
|
|
||||||
[255] = 0,
|
|
||||||
|
|
||||||
/* more colors can be added after 255 to use with DefaultXX */
|
|
||||||
"#2e3440", /* background */
|
|
||||||
"#d8dee9", /* foreground */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default colors (colorname index)
|
|
||||||
* foreground, background, cursor, reverse cursor
|
|
||||||
*/
|
|
||||||
unsigned int defaultfg = 257;
|
|
||||||
unsigned int defaultbg = 256;
|
|
||||||
static unsigned int defaultcs = 257;
|
|
||||||
static unsigned int defaultrcs = 256;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default shape of cursor
|
|
||||||
* 2: Block ("█")
|
|
||||||
* 4: Underline ("_")
|
|
||||||
* 6: Bar ("|")
|
|
||||||
* 7: Snowman ("☃")
|
|
||||||
*/
|
|
||||||
static unsigned int cursorshape = 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default columns and rows numbers
|
|
||||||
*/
|
|
||||||
|
|
||||||
static unsigned int cols = 80;
|
|
||||||
static unsigned int rows = 24;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default colour and shape of the mouse cursor
|
|
||||||
*/
|
|
||||||
static unsigned int mouseshape = XC_xterm;
|
|
||||||
static unsigned int mousefg = 7;
|
|
||||||
static unsigned int mousebg = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Color used to display font attributes when fontconfig selected a font which
|
|
||||||
* doesn't match the ones requested.
|
|
||||||
*/
|
|
||||||
static unsigned int defaultattr = 11;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
|
|
||||||
* Note that if you want to use ShiftMask with selmasks, set this to an other
|
|
||||||
* modifier, set to 0 to not use it.
|
|
||||||
*/
|
|
||||||
static uint forcemousemod = ShiftMask;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Internal mouse shortcuts.
|
|
||||||
* Beware that overloading Button1 will disable the selection.
|
|
||||||
*/
|
|
||||||
static MouseShortcut mshortcuts[] = {
|
|
||||||
/* mask button function argument release */
|
|
||||||
{ ShiftMask, Button4, kscrollup, {.i = 1} },
|
|
||||||
{ ShiftMask, Button5, kscrolldown, {.i = 1} },
|
|
||||||
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
|
||||||
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
|
|
||||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
|
||||||
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
|
|
||||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Internal keyboard shortcuts. */
|
|
||||||
#define MODKEY Mod1Mask
|
|
||||||
#define TERMMOD (ControlMask|ShiftMask)
|
|
||||||
|
|
||||||
static Shortcut shortcuts[] = {
|
|
||||||
/* mask keysym function argument */
|
|
||||||
{ XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
|
|
||||||
{ ControlMask, XK_Print, toggleprinter, {.i = 0} },
|
|
||||||
{ ShiftMask, XK_Print, printscreen, {.i = 0} },
|
|
||||||
{ XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
|
|
||||||
{ TERMMOD, XK_Prior, zoom, {.f = +1} },
|
|
||||||
{ TERMMOD, XK_Next, zoom, {.f = -1} },
|
|
||||||
{ TERMMOD, XK_Home, zoomreset, {.f = 0} },
|
|
||||||
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
|
|
||||||
{ TERMMOD, XK_V, clippaste, {.i = 0} },
|
|
||||||
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
|
||||||
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
|
||||||
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
|
||||||
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
|
||||||
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Special keys (change & recompile st.info accordingly)
|
|
||||||
*
|
|
||||||
* Mask value:
|
|
||||||
* * Use XK_ANY_MOD to match the key no matter modifiers state
|
|
||||||
* * Use XK_NO_MOD to match the key alone (no modifiers)
|
|
||||||
* appkey value:
|
|
||||||
* * 0: no value
|
|
||||||
* * > 0: keypad application mode enabled
|
|
||||||
* * = 2: term.numlock = 1
|
|
||||||
* * < 0: keypad application mode disabled
|
|
||||||
* appcursor value:
|
|
||||||
* * 0: no value
|
|
||||||
* * > 0: cursor application mode enabled
|
|
||||||
* * < 0: cursor application mode disabled
|
|
||||||
*
|
|
||||||
* Be careful with the order of the definitions because st searches in
|
|
||||||
* this table sequentially, so any XK_ANY_MOD must be in the last
|
|
||||||
* position for a key.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If you want keys other than the X11 function keys (0xFD00 - 0xFFFF)
|
|
||||||
* to be mapped below, add them to this array.
|
|
||||||
*/
|
|
||||||
static KeySym mappedkeys[] = { -1 };
|
|
||||||
|
|
||||||
/*
|
|
||||||
* State bits to ignore when matching key or button events. By default,
|
|
||||||
* numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
|
|
||||||
*/
|
|
||||||
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the huge key array which defines all compatibility to the Linux
|
|
||||||
* world. Please decide about changes wisely.
|
|
||||||
*/
|
|
||||||
static Key key[] = {
|
|
||||||
/* keysym mask string appkey appcursor */
|
|
||||||
{ XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
|
|
||||||
{ XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
|
|
||||||
{ XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
|
|
||||||
{ XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
|
|
||||||
{ XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
|
|
||||||
{ XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
|
|
||||||
{ XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
|
|
||||||
{ XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
|
|
||||||
{ XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
|
|
||||||
{ XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
|
|
||||||
{ XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
|
|
||||||
{ XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
|
|
||||||
{ XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
|
|
||||||
{ XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
|
|
||||||
{ XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
|
|
||||||
{ XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
|
|
||||||
{ XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
|
|
||||||
{ XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
|
|
||||||
{ XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
|
|
||||||
{ XK_KP_End, ControlMask, "\033[J", -1, 0},
|
|
||||||
{ XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
|
|
||||||
{ XK_KP_End, ShiftMask, "\033[K", -1, 0},
|
|
||||||
{ XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
|
|
||||||
{ XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
|
|
||||||
{ XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
|
|
||||||
{ XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
|
|
||||||
{ XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
|
|
||||||
{ XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
|
|
||||||
{ XK_KP_Insert, ControlMask, "\033[L", -1, 0},
|
|
||||||
{ XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
|
|
||||||
{ XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
|
|
||||||
{ XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
|
|
||||||
{ XK_KP_Delete, ControlMask, "\033[M", -1, 0},
|
|
||||||
{ XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
|
|
||||||
{ XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
|
|
||||||
{ XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
|
|
||||||
{ XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
|
|
||||||
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
|
|
||||||
{ XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
|
|
||||||
{ XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
|
|
||||||
{ XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
|
|
||||||
{ XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
|
|
||||||
{ XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
|
|
||||||
{ XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
|
|
||||||
{ XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
|
|
||||||
{ XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
|
|
||||||
{ XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
|
|
||||||
{ XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
|
|
||||||
{ XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
|
|
||||||
{ XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
|
|
||||||
{ XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
|
|
||||||
{ XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
|
|
||||||
{ XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
|
|
||||||
{ XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
|
|
||||||
{ XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
|
|
||||||
{ XK_Up, ShiftMask, "\033[1;2A", 0, 0},
|
|
||||||
{ XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
|
|
||||||
{ XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0},
|
|
||||||
{ XK_Up, ControlMask, "\033[1;5A", 0, 0},
|
|
||||||
{ XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0},
|
|
||||||
{ XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0},
|
|
||||||
{ XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0},
|
|
||||||
{ XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
|
|
||||||
{ XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
|
|
||||||
{ XK_Down, ShiftMask, "\033[1;2B", 0, 0},
|
|
||||||
{ XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
|
|
||||||
{ XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0},
|
|
||||||
{ XK_Down, ControlMask, "\033[1;5B", 0, 0},
|
|
||||||
{ XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0},
|
|
||||||
{ XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0},
|
|
||||||
{ XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0},
|
|
||||||
{ XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
|
|
||||||
{ XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
|
|
||||||
{ XK_Left, ShiftMask, "\033[1;2D", 0, 0},
|
|
||||||
{ XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
|
|
||||||
{ XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0},
|
|
||||||
{ XK_Left, ControlMask, "\033[1;5D", 0, 0},
|
|
||||||
{ XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0},
|
|
||||||
{ XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0},
|
|
||||||
{ XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0},
|
|
||||||
{ XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
|
|
||||||
{ XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
|
|
||||||
{ XK_Right, ShiftMask, "\033[1;2C", 0, 0},
|
|
||||||
{ XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
|
|
||||||
{ XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0},
|
|
||||||
{ XK_Right, ControlMask, "\033[1;5C", 0, 0},
|
|
||||||
{ XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0},
|
|
||||||
{ XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0},
|
|
||||||
{ XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0},
|
|
||||||
{ XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
|
|
||||||
{ XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
|
|
||||||
{ XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
|
|
||||||
{ XK_Return, Mod1Mask, "\033\r", 0, 0},
|
|
||||||
{ XK_Return, XK_ANY_MOD, "\r", 0, 0},
|
|
||||||
{ XK_Insert, ShiftMask, "\033[4l", -1, 0},
|
|
||||||
{ XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
|
|
||||||
{ XK_Insert, ControlMask, "\033[L", -1, 0},
|
|
||||||
{ XK_Insert, ControlMask, "\033[2;5~", +1, 0},
|
|
||||||
{ XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
|
|
||||||
{ XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
|
|
||||||
{ XK_Delete, ControlMask, "\033[M", -1, 0},
|
|
||||||
{ XK_Delete, ControlMask, "\033[3;5~", +1, 0},
|
|
||||||
{ XK_Delete, ShiftMask, "\033[2K", -1, 0},
|
|
||||||
{ XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
|
|
||||||
{ XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
|
|
||||||
{ XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
|
|
||||||
{ XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
|
|
||||||
{ XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
|
|
||||||
{ XK_Home, ShiftMask, "\033[2J", 0, -1},
|
|
||||||
{ XK_Home, ShiftMask, "\033[1;2H", 0, +1},
|
|
||||||
{ XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
|
|
||||||
{ XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
|
|
||||||
{ XK_End, ControlMask, "\033[J", -1, 0},
|
|
||||||
{ XK_End, ControlMask, "\033[1;5F", +1, 0},
|
|
||||||
{ XK_End, ShiftMask, "\033[K", -1, 0},
|
|
||||||
{ XK_End, ShiftMask, "\033[1;2F", +1, 0},
|
|
||||||
{ XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
|
|
||||||
{ XK_Prior, ControlMask, "\033[5;5~", 0, 0},
|
|
||||||
{ XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
|
|
||||||
{ XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
|
|
||||||
{ XK_Next, ControlMask, "\033[6;5~", 0, 0},
|
|
||||||
{ XK_Next, ShiftMask, "\033[6;2~", 0, 0},
|
|
||||||
{ XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
|
|
||||||
{ XK_F1, XK_NO_MOD, "\033OP" , 0, 0},
|
|
||||||
{ XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
|
|
||||||
{ XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
|
|
||||||
{ XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
|
|
||||||
{ XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
|
|
||||||
{ XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
|
|
||||||
{ XK_F2, XK_NO_MOD, "\033OQ" , 0, 0},
|
|
||||||
{ XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
|
|
||||||
{ XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
|
|
||||||
{ XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
|
|
||||||
{ XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
|
|
||||||
{ XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
|
|
||||||
{ XK_F3, XK_NO_MOD, "\033OR" , 0, 0},
|
|
||||||
{ XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
|
|
||||||
{ XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
|
|
||||||
{ XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
|
|
||||||
{ XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
|
|
||||||
{ XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
|
|
||||||
{ XK_F4, XK_NO_MOD, "\033OS" , 0, 0},
|
|
||||||
{ XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
|
|
||||||
{ XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
|
|
||||||
{ XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
|
|
||||||
{ XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
|
|
||||||
{ XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
|
|
||||||
{ XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
|
|
||||||
{ XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
|
|
||||||
{ XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
|
|
||||||
{ XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
|
|
||||||
{ XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
|
|
||||||
{ XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
|
|
||||||
{ XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
|
|
||||||
{ XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
|
|
||||||
{ XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
|
|
||||||
{ XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
|
|
||||||
{ XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
|
|
||||||
{ XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
|
|
||||||
{ XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
|
|
||||||
{ XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
|
|
||||||
{ XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
|
|
||||||
{ XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
|
|
||||||
{ XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
|
|
||||||
{ XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
|
|
||||||
{ XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
|
|
||||||
{ XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
|
|
||||||
{ XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
|
|
||||||
{ XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
|
|
||||||
{ XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
|
|
||||||
{ XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
|
|
||||||
{ XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
|
|
||||||
{ XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
|
|
||||||
{ XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
|
|
||||||
{ XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
|
|
||||||
{ XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
|
|
||||||
{ XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
|
|
||||||
{ XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
|
|
||||||
{ XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
|
|
||||||
{ XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
|
|
||||||
{ XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
|
|
||||||
{ XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
|
|
||||||
{ XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
|
|
||||||
{ XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
|
|
||||||
{ XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
|
|
||||||
{ XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
|
|
||||||
{ XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
|
|
||||||
{ XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
|
|
||||||
{ XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
|
|
||||||
{ XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
|
|
||||||
{ XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
|
|
||||||
{ XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
|
|
||||||
{ XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
|
|
||||||
{ XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
|
|
||||||
{ XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
|
|
||||||
{ XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
|
|
||||||
{ XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
|
|
||||||
{ XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
|
|
||||||
{ XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
|
|
||||||
{ XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
|
|
||||||
{ XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
|
|
||||||
{ XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
|
|
||||||
{ XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
|
|
||||||
{ XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
|
|
||||||
{ XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
|
|
||||||
{ XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
|
|
||||||
{ XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
|
|
||||||
{ XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
|
|
||||||
{ XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Selection types' masks.
|
|
||||||
* Use the same masks as usual.
|
|
||||||
* Button1Mask is always unset, to make masks match between ButtonPress.
|
|
||||||
* ButtonRelease and MotionNotify.
|
|
||||||
* If no match is found, regular selection is used.
|
|
||||||
*/
|
|
||||||
static uint selmasks[] = {
|
|
||||||
[SEL_RECTANGULAR] = Mod1Mask,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Printable characters in ASCII, used to estimate the advance width
|
|
||||||
* of single wide characters.
|
|
||||||
*/
|
|
||||||
static char ascii_printable[] =
|
|
||||||
" !\"#$%&'()*+,-./0123456789:;<=>?"
|
|
||||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
|
||||||
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* plumb_cmd is run on mouse button 3 click, with argument set to
|
|
||||||
* current selection and with cwd set to the cwd of the active shell
|
|
||||||
*/
|
|
||||||
static char *plumb_cmd = "plumb";
|
|
@ -1,19 +0,0 @@
|
|||||||
--- config.def.h
|
|
||||||
+++ config.def.h
|
|
||||||
@@ -112,6 +115,7 @@ static const char *colorname[] = {
|
|
||||||
/* more colors can be added after 255 to use with DefaultXX */
|
|
||||||
"#cccccc",
|
|
||||||
"#555555",
|
|
||||||
+ "black",
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
@@ -120,7 +124,7 @@ static const char *colorname[] = {
|
|
||||||
* foreground, background, cursor, reverse cursor
|
|
||||||
*/
|
|
||||||
unsigned int defaultfg = 7;
|
|
||||||
-unsigned int defaultbg = 0;
|
|
||||||
+unsigned int defaultbg = 258;
|
|
||||||
static unsigned int defaultcs = 256;
|
|
||||||
static unsigned int defaultrcs = 257;
|
|
||||||
|
|
@ -1,485 +0,0 @@
|
|||||||
/* See LICENSE file for copyright and license details. */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* appearance
|
|
||||||
*
|
|
||||||
* font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
|
|
||||||
*/
|
|
||||||
static char *font = "MesloLGS NF:pixelsize=15:antialias=true:autohint=true";
|
|
||||||
static int borderpx = 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* What program is execed by st depends of these precedence rules:
|
|
||||||
* 1: program passed with -e
|
|
||||||
* 2: scroll and/or utmp
|
|
||||||
* 3: SHELL environment variable
|
|
||||||
* 4: value of shell in /etc/passwd
|
|
||||||
* 5: value of shell in config.h
|
|
||||||
*/
|
|
||||||
static char *shell = "/bin/sh";
|
|
||||||
char *utmp = NULL;
|
|
||||||
/* scroll program: to enable use a string like "scroll" */
|
|
||||||
char *scroll = NULL;
|
|
||||||
char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
|
|
||||||
|
|
||||||
/* identification sequence returned in DA and DECID */
|
|
||||||
char *vtiden = "\033[?6c";
|
|
||||||
|
|
||||||
/* Kerning / character bounding-box multipliers */
|
|
||||||
static float cwscale = 1.0;
|
|
||||||
static float chscale = 1.0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* word delimiter string
|
|
||||||
*
|
|
||||||
* More advanced example: L" `'\"()[]{}"
|
|
||||||
*/
|
|
||||||
wchar_t *worddelimiters = L" ";
|
|
||||||
|
|
||||||
/* selection timeouts (in milliseconds) */
|
|
||||||
static unsigned int doubleclicktimeout = 300;
|
|
||||||
static unsigned int tripleclicktimeout = 600;
|
|
||||||
|
|
||||||
/* alt screens */
|
|
||||||
int allowaltscreen = 1;
|
|
||||||
|
|
||||||
/* allow certain non-interactive (insecure) window operations such as:
|
|
||||||
setting the clipboard text */
|
|
||||||
int allowwindowops = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* draw latency range in ms - from new content/keypress/etc until drawing.
|
|
||||||
* within this range, st draws when content stops arriving (idle). mostly it's
|
|
||||||
* near minlatency, but it waits longer for slow updates to avoid partial draw.
|
|
||||||
* low minlatency will tear/flicker more, as it can "detect" idle too early.
|
|
||||||
*/
|
|
||||||
static double minlatency = 8;
|
|
||||||
static double maxlatency = 33;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* blinking timeout (set to 0 to disable blinking) for the terminal blinking
|
|
||||||
* attribute.
|
|
||||||
*/
|
|
||||||
static unsigned int blinktimeout = 800;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* thickness of underline and bar cursors
|
|
||||||
*/
|
|
||||||
static unsigned int cursorthickness = 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* bell volume. It must be a value between -100 and 100. Use 0 for disabling
|
|
||||||
* it
|
|
||||||
*/
|
|
||||||
static int bellvolume = 0;
|
|
||||||
|
|
||||||
/* default TERM value */
|
|
||||||
char *termname = "st-256color";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* spaces per tab
|
|
||||||
*
|
|
||||||
* When you are changing this value, don't forget to adapt the »it« value in
|
|
||||||
* the st.info and appropriately install the st.info in the environment where
|
|
||||||
* you use this st version.
|
|
||||||
*
|
|
||||||
* it#$tabspaces,
|
|
||||||
*
|
|
||||||
* Secondly make sure your kernel is not expanding tabs. When running `stty
|
|
||||||
* -a` »tab0« should appear. You can tell the terminal to not expand tabs by
|
|
||||||
* running following command:
|
|
||||||
*
|
|
||||||
* stty tabs
|
|
||||||
*/
|
|
||||||
unsigned int tabspaces = 8;
|
|
||||||
|
|
||||||
/* bg opacity */
|
|
||||||
float alpha = 0.95;
|
|
||||||
|
|
||||||
/* Terminal colors (16 first used in escape sequence) */
|
|
||||||
static const char *colorname[] = {
|
|
||||||
/* 8 normal colors */
|
|
||||||
"#3b4252", /* black */
|
|
||||||
"#bf616a", /* red */
|
|
||||||
"#a3be8c", /* green */
|
|
||||||
"#ebcb8b", /* yellow */
|
|
||||||
"#81a1c1", /* blue */
|
|
||||||
"#b48ead", /* magenta */
|
|
||||||
"#88c0d0", /* cyan */
|
|
||||||
"#e5e9f0", /* white */
|
|
||||||
|
|
||||||
/* 8 bright colors */
|
|
||||||
"#4c566a", /* black */
|
|
||||||
"#bf616a", /* red */
|
|
||||||
"#a3be8c", /* green */
|
|
||||||
"#ebcb8b", /* yellow */
|
|
||||||
"#81a1c1", /* blue */
|
|
||||||
"#b48ead", /* magenta */
|
|
||||||
"#8fbcbb", /* cyan */
|
|
||||||
"#eceff4", /* white */
|
|
||||||
|
|
||||||
[255] = 0,
|
|
||||||
|
|
||||||
/* more colors can be added after 255 to use with DefaultXX */
|
|
||||||
"#2e3440", /* background */
|
|
||||||
"#d8dee9", /* foreground */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default colors (colorname index)
|
|
||||||
* foreground, background, cursor, reverse cursor
|
|
||||||
*/
|
|
||||||
unsigned int defaultfg = 257;
|
|
||||||
unsigned int defaultbg = 256;
|
|
||||||
static unsigned int defaultcs = 257;
|
|
||||||
static unsigned int defaultrcs = 256;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default shape of cursor
|
|
||||||
* 2: Block ("█")
|
|
||||||
* 4: Underline ("_")
|
|
||||||
* 6: Bar ("|")
|
|
||||||
* 7: Snowman ("☃")
|
|
||||||
*/
|
|
||||||
static unsigned int cursorshape = 2;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default columns and rows numbers
|
|
||||||
*/
|
|
||||||
|
|
||||||
static unsigned int cols = 80;
|
|
||||||
static unsigned int rows = 24;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Default colour and shape of the mouse cursor
|
|
||||||
*/
|
|
||||||
static unsigned int mouseshape = XC_xterm;
|
|
||||||
static unsigned int mousefg = 7;
|
|
||||||
static unsigned int mousebg = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Color used to display font attributes when fontconfig selected a font which
|
|
||||||
* doesn't match the ones requested.
|
|
||||||
*/
|
|
||||||
static unsigned int defaultattr = 11;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
|
|
||||||
* Note that if you want to use ShiftMask with selmasks, set this to an other
|
|
||||||
* modifier, set to 0 to not use it.
|
|
||||||
*/
|
|
||||||
static uint forcemousemod = ShiftMask;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Internal mouse shortcuts.
|
|
||||||
* Beware that overloading Button1 will disable the selection.
|
|
||||||
*/
|
|
||||||
static MouseShortcut mshortcuts[] = {
|
|
||||||
/* mask button function argument release */
|
|
||||||
{ ShiftMask, Button4, kscrollup, {.i = 1} },
|
|
||||||
{ ShiftMask, Button5, kscrolldown, {.i = 1} },
|
|
||||||
{ XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
|
|
||||||
{ ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
|
|
||||||
{ XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
|
|
||||||
{ ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
|
|
||||||
{ XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Internal keyboard shortcuts. */
|
|
||||||
#define MODKEY Mod1Mask
|
|
||||||
#define TERMMOD (ControlMask|ShiftMask)
|
|
||||||
|
|
||||||
static Shortcut shortcuts[] = {
|
|
||||||
/* mask keysym function argument */
|
|
||||||
{ XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
|
|
||||||
{ ControlMask, XK_Print, toggleprinter, {.i = 0} },
|
|
||||||
{ ShiftMask, XK_Print, printscreen, {.i = 0} },
|
|
||||||
{ XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
|
|
||||||
{ TERMMOD, XK_Prior, zoom, {.f = +1} },
|
|
||||||
{ TERMMOD, XK_Next, zoom, {.f = -1} },
|
|
||||||
{ TERMMOD, XK_Home, zoomreset, {.f = 0} },
|
|
||||||
{ TERMMOD, XK_C, clipcopy, {.i = 0} },
|
|
||||||
{ TERMMOD, XK_V, clippaste, {.i = 0} },
|
|
||||||
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
|
||||||
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
|
||||||
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
|
||||||
{ ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
|
|
||||||
{ ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Special keys (change & recompile st.info accordingly)
|
|
||||||
*
|
|
||||||
* Mask value:
|
|
||||||
* * Use XK_ANY_MOD to match the key no matter modifiers state
|
|
||||||
* * Use XK_NO_MOD to match the key alone (no modifiers)
|
|
||||||
* appkey value:
|
|
||||||
* * 0: no value
|
|
||||||
* * > 0: keypad application mode enabled
|
|
||||||
* * = 2: term.numlock = 1
|
|
||||||
* * < 0: keypad application mode disabled
|
|
||||||
* appcursor value:
|
|
||||||
* * 0: no value
|
|
||||||
* * > 0: cursor application mode enabled
|
|
||||||
* * < 0: cursor application mode disabled
|
|
||||||
*
|
|
||||||
* Be careful with the order of the definitions because st searches in
|
|
||||||
* this table sequentially, so any XK_ANY_MOD must be in the last
|
|
||||||
* position for a key.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If you want keys other than the X11 function keys (0xFD00 - 0xFFFF)
|
|
||||||
* to be mapped below, add them to this array.
|
|
||||||
*/
|
|
||||||
static KeySym mappedkeys[] = { -1 };
|
|
||||||
|
|
||||||
/*
|
|
||||||
* State bits to ignore when matching key or button events. By default,
|
|
||||||
* numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
|
|
||||||
*/
|
|
||||||
static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This is the huge key array which defines all compatibility to the Linux
|
|
||||||
* world. Please decide about changes wisely.
|
|
||||||
*/
|
|
||||||
static Key key[] = {
|
|
||||||
/* keysym mask string appkey appcursor */
|
|
||||||
{ XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
|
|
||||||
{ XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
|
|
||||||
{ XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
|
|
||||||
{ XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
|
|
||||||
{ XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
|
|
||||||
{ XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
|
|
||||||
{ XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
|
|
||||||
{ XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
|
|
||||||
{ XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
|
|
||||||
{ XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
|
|
||||||
{ XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
|
|
||||||
{ XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
|
|
||||||
{ XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
|
|
||||||
{ XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
|
|
||||||
{ XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
|
|
||||||
{ XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
|
|
||||||
{ XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
|
|
||||||
{ XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
|
|
||||||
{ XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
|
|
||||||
{ XK_KP_End, ControlMask, "\033[J", -1, 0},
|
|
||||||
{ XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
|
|
||||||
{ XK_KP_End, ShiftMask, "\033[K", -1, 0},
|
|
||||||
{ XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
|
|
||||||
{ XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
|
|
||||||
{ XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
|
|
||||||
{ XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
|
|
||||||
{ XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
|
|
||||||
{ XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
|
|
||||||
{ XK_KP_Insert, ControlMask, "\033[L", -1, 0},
|
|
||||||
{ XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
|
|
||||||
{ XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
|
|
||||||
{ XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
|
|
||||||
{ XK_KP_Delete, ControlMask, "\033[M", -1, 0},
|
|
||||||
{ XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
|
|
||||||
{ XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
|
|
||||||
{ XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
|
|
||||||
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~", -1, 0},
|
|
||||||
{ XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
|
|
||||||
{ XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
|
|
||||||
{ XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
|
|
||||||
{ XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
|
|
||||||
{ XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
|
|
||||||
{ XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
|
|
||||||
{ XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
|
|
||||||
{ XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
|
|
||||||
{ XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
|
|
||||||
{ XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
|
|
||||||
{ XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
|
|
||||||
{ XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
|
|
||||||
{ XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
|
|
||||||
{ XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
|
|
||||||
{ XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
|
|
||||||
{ XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
|
|
||||||
{ XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
|
|
||||||
{ XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
|
|
||||||
{ XK_Up, ShiftMask, "\033[1;2A", 0, 0},
|
|
||||||
{ XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
|
|
||||||
{ XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0},
|
|
||||||
{ XK_Up, ControlMask, "\033[1;5A", 0, 0},
|
|
||||||
{ XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0},
|
|
||||||
{ XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0},
|
|
||||||
{ XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0},
|
|
||||||
{ XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
|
|
||||||
{ XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
|
|
||||||
{ XK_Down, ShiftMask, "\033[1;2B", 0, 0},
|
|
||||||
{ XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
|
|
||||||
{ XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0},
|
|
||||||
{ XK_Down, ControlMask, "\033[1;5B", 0, 0},
|
|
||||||
{ XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0},
|
|
||||||
{ XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0},
|
|
||||||
{ XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0},
|
|
||||||
{ XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
|
|
||||||
{ XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
|
|
||||||
{ XK_Left, ShiftMask, "\033[1;2D", 0, 0},
|
|
||||||
{ XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
|
|
||||||
{ XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0},
|
|
||||||
{ XK_Left, ControlMask, "\033[1;5D", 0, 0},
|
|
||||||
{ XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0},
|
|
||||||
{ XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0},
|
|
||||||
{ XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0},
|
|
||||||
{ XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
|
|
||||||
{ XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
|
|
||||||
{ XK_Right, ShiftMask, "\033[1;2C", 0, 0},
|
|
||||||
{ XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
|
|
||||||
{ XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0},
|
|
||||||
{ XK_Right, ControlMask, "\033[1;5C", 0, 0},
|
|
||||||
{ XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0},
|
|
||||||
{ XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0},
|
|
||||||
{ XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0},
|
|
||||||
{ XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
|
|
||||||
{ XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
|
|
||||||
{ XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
|
|
||||||
{ XK_Return, Mod1Mask, "\033\r", 0, 0},
|
|
||||||
{ XK_Return, XK_ANY_MOD, "\r", 0, 0},
|
|
||||||
{ XK_Insert, ShiftMask, "\033[4l", -1, 0},
|
|
||||||
{ XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
|
|
||||||
{ XK_Insert, ControlMask, "\033[L", -1, 0},
|
|
||||||
{ XK_Insert, ControlMask, "\033[2;5~", +1, 0},
|
|
||||||
{ XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
|
|
||||||
{ XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
|
|
||||||
{ XK_Delete, ControlMask, "\033[M", -1, 0},
|
|
||||||
{ XK_Delete, ControlMask, "\033[3;5~", +1, 0},
|
|
||||||
{ XK_Delete, ShiftMask, "\033[2K", -1, 0},
|
|
||||||
{ XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
|
|
||||||
{ XK_Delete, XK_ANY_MOD, "\033[3~", -1, 0},
|
|
||||||
{ XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
|
|
||||||
{ XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
|
|
||||||
{ XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
|
|
||||||
{ XK_Home, ShiftMask, "\033[2J", 0, -1},
|
|
||||||
{ XK_Home, ShiftMask, "\033[1;2H", 0, +1},
|
|
||||||
{ XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
|
|
||||||
{ XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
|
|
||||||
{ XK_End, ControlMask, "\033[J", -1, 0},
|
|
||||||
{ XK_End, ControlMask, "\033[1;5F", +1, 0},
|
|
||||||
{ XK_End, ShiftMask, "\033[K", -1, 0},
|
|
||||||
{ XK_End, ShiftMask, "\033[1;2F", +1, 0},
|
|
||||||
{ XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
|
|
||||||
{ XK_Prior, ControlMask, "\033[5;5~", 0, 0},
|
|
||||||
{ XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
|
|
||||||
{ XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
|
|
||||||
{ XK_Next, ControlMask, "\033[6;5~", 0, 0},
|
|
||||||
{ XK_Next, ShiftMask, "\033[6;2~", 0, 0},
|
|
||||||
{ XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
|
|
||||||
{ XK_F1, XK_NO_MOD, "\033OP" , 0, 0},
|
|
||||||
{ XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
|
|
||||||
{ XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
|
|
||||||
{ XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
|
|
||||||
{ XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
|
|
||||||
{ XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
|
|
||||||
{ XK_F2, XK_NO_MOD, "\033OQ" , 0, 0},
|
|
||||||
{ XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
|
|
||||||
{ XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
|
|
||||||
{ XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
|
|
||||||
{ XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
|
|
||||||
{ XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
|
|
||||||
{ XK_F3, XK_NO_MOD, "\033OR" , 0, 0},
|
|
||||||
{ XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
|
|
||||||
{ XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
|
|
||||||
{ XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
|
|
||||||
{ XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
|
|
||||||
{ XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
|
|
||||||
{ XK_F4, XK_NO_MOD, "\033OS" , 0, 0},
|
|
||||||
{ XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
|
|
||||||
{ XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
|
|
||||||
{ XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
|
|
||||||
{ XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
|
|
||||||
{ XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
|
|
||||||
{ XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
|
|
||||||
{ XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
|
|
||||||
{ XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
|
|
||||||
{ XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
|
|
||||||
{ XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
|
|
||||||
{ XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
|
|
||||||
{ XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
|
|
||||||
{ XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
|
|
||||||
{ XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
|
|
||||||
{ XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
|
|
||||||
{ XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
|
|
||||||
{ XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
|
|
||||||
{ XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
|
|
||||||
{ XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
|
|
||||||
{ XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
|
|
||||||
{ XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
|
|
||||||
{ XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
|
|
||||||
{ XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
|
|
||||||
{ XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
|
|
||||||
{ XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
|
|
||||||
{ XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
|
|
||||||
{ XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
|
|
||||||
{ XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
|
|
||||||
{ XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
|
|
||||||
{ XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
|
|
||||||
{ XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
|
|
||||||
{ XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
|
|
||||||
{ XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
|
|
||||||
{ XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
|
|
||||||
{ XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
|
|
||||||
{ XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
|
|
||||||
{ XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
|
|
||||||
{ XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
|
|
||||||
{ XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
|
|
||||||
{ XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
|
|
||||||
{ XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
|
|
||||||
{ XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
|
|
||||||
{ XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
|
|
||||||
{ XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
|
|
||||||
{ XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
|
|
||||||
{ XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
|
|
||||||
{ XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
|
|
||||||
{ XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
|
|
||||||
{ XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
|
|
||||||
{ XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
|
|
||||||
{ XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
|
|
||||||
{ XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
|
|
||||||
{ XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
|
|
||||||
{ XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
|
|
||||||
{ XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
|
|
||||||
{ XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
|
|
||||||
{ XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
|
|
||||||
{ XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
|
|
||||||
{ XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
|
|
||||||
{ XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
|
|
||||||
{ XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
|
|
||||||
{ XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
|
|
||||||
{ XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
|
|
||||||
{ XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
|
|
||||||
{ XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
|
|
||||||
{ XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
|
|
||||||
{ XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Selection types' masks.
|
|
||||||
* Use the same masks as usual.
|
|
||||||
* Button1Mask is always unset, to make masks match between ButtonPress.
|
|
||||||
* ButtonRelease and MotionNotify.
|
|
||||||
* If no match is found, regular selection is used.
|
|
||||||
*/
|
|
||||||
static uint selmasks[] = {
|
|
||||||
[SEL_RECTANGULAR] = Mod1Mask,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Printable characters in ASCII, used to estimate the advance width
|
|
||||||
* of single wide characters.
|
|
||||||
*/
|
|
||||||
static char ascii_printable[] =
|
|
||||||
" !\"#$%&'()*+,-./0123456789:;<=>?"
|
|
||||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
|
||||||
"`abcdefghijklmnopqrstuvwxyz{|}~";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* plumb_cmd is run on mouse button 3 click, with argument set to
|
|
||||||
* current selection and with cwd set to the cwd of the active shell
|
|
||||||
*/
|
|
||||||
static char *plumb_cmd = "plumb";
|
|
79
st-0.8.4/patches/st-newterm-0.8.2.diff
Normal file
79
st-0.8.4/patches/st-newterm-0.8.2.diff
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
From a7eedc85e0609177cdb1ed3f6203fa37e6420012 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Matias Lang <yo@matiaslang.me>
|
||||||
|
Date: Wed, 17 Jul 2019 01:10:44 -0300
|
||||||
|
Subject: [PATCH] Add shortcut to spawn new terminal in the current dir
|
||||||
|
|
||||||
|
Ctrl-Shift-Return now creates a new ST terminal, whose CWD is the same
|
||||||
|
as the parent st's CWD
|
||||||
|
---
|
||||||
|
config.def.h | 1 +
|
||||||
|
st.c | 21 +++++++++++++++++++++
|
||||||
|
st.h | 1 +
|
||||||
|
3 files changed, 23 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 0e01717..31f26d8 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -178,6 +178,7 @@ static Shortcut shortcuts[] = {
|
||||||
|
{ TERMMOD, XK_Y, selpaste, {.i = 0} },
|
||||||
|
{ ShiftMask, XK_Insert, selpaste, {.i = 0} },
|
||||||
|
{ TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
|
||||||
|
+ { TERMMOD, XK_Return, newterm, {.i = 0} },
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
diff --git a/st.c b/st.c
|
||||||
|
index b8e6077..044e29b 100644
|
||||||
|
--- a/st.c
|
||||||
|
+++ b/st.c
|
||||||
|
@@ -153,6 +153,7 @@ typedef struct {
|
||||||
|
} STREscape;
|
||||||
|
|
||||||
|
static void execsh(char *, char **);
|
||||||
|
+static char *getcwd_by_pid(pid_t pid);
|
||||||
|
static void stty(char **);
|
||||||
|
static void sigchld(int);
|
||||||
|
static void ttywriteraw(const char *, size_t);
|
||||||
|
@@ -1059,6 +1060,26 @@ tswapscreen(void)
|
||||||
|
tfulldirt();
|
||||||
|
}
|
||||||
|
|
||||||
|
+void
|
||||||
|
+newterm(const Arg* a)
|
||||||
|
+{
|
||||||
|
+ switch (fork()) {
|
||||||
|
+ case -1:
|
||||||
|
+ die("fork failed: %s\n", strerror(errno));
|
||||||
|
+ break;
|
||||||
|
+ case 0:
|
||||||
|
+ chdir(getcwd_by_pid(pid));
|
||||||
|
+ execlp("st", "./st", NULL);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static char *getcwd_by_pid(pid_t pid) {
|
||||||
|
+ char buf[32];
|
||||||
|
+ snprintf(buf, sizeof buf, "/proc/%d/cwd", pid);
|
||||||
|
+ return realpath(buf, NULL);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
tscrolldown(int orig, int n)
|
||||||
|
{
|
||||||
|
diff --git a/st.h b/st.h
|
||||||
|
index 38c61c4..54d4a43 100644
|
||||||
|
--- a/st.h
|
||||||
|
+++ b/st.h
|
||||||
|
@@ -80,6 +80,7 @@ void die(const char *, ...);
|
||||||
|
void redraw(void);
|
||||||
|
void draw(void);
|
||||||
|
|
||||||
|
+void newterm(const Arg *);
|
||||||
|
void printscreen(const Arg *);
|
||||||
|
void printsel(const Arg *);
|
||||||
|
void sendbreak(const Arg *);
|
||||||
|
--
|
||||||
|
2.19.2
|
||||||
|
|
@ -163,6 +163,7 @@ typedef struct {
|
|||||||
} STREscape;
|
} STREscape;
|
||||||
|
|
||||||
static void execsh(char *, char **);
|
static void execsh(char *, char **);
|
||||||
|
static char *getcwd_by_pid(pid_t pid);
|
||||||
static void stty(char **);
|
static void stty(char **);
|
||||||
static void sigchld(int);
|
static void sigchld(int);
|
||||||
static void ttywriteraw(const char *, size_t);
|
static void ttywriteraw(const char *, size_t);
|
||||||
@ -1068,6 +1069,26 @@ treset(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
newterm(const Arg* a)
|
||||||
|
{
|
||||||
|
switch (fork()) {
|
||||||
|
case -1:
|
||||||
|
die("fork failed: %s\n", strerror(errno));
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
chdir(getcwd_by_pid(pid));
|
||||||
|
execlp("st", "./st", NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *getcwd_by_pid(pid_t pid) {
|
||||||
|
char buf[32];
|
||||||
|
snprintf(buf, sizeof buf, "/proc/%d/cwd", pid);
|
||||||
|
return realpath(buf, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tnew(int col, int row)
|
tnew(int col, int row)
|
||||||
{
|
{
|
||||||
|
2616
st-0.8.4/st.c.orig
2616
st-0.8.4/st.c.orig
File diff suppressed because it is too large
Load Diff
@ -1,127 +0,0 @@
|
|||||||
/* See LICENSE for license details. */
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
/* macros */
|
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
||||||
#define MAX(a, b) ((a) < (b) ? (b) : (a))
|
|
||||||
#define LEN(a) (sizeof(a) / sizeof(a)[0])
|
|
||||||
#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
|
|
||||||
#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
|
|
||||||
#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
|
|
||||||
#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
|
|
||||||
#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \
|
|
||||||
(a).bg != (b).bg)
|
|
||||||
#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
|
|
||||||
(t1.tv_nsec-t2.tv_nsec)/1E6)
|
|
||||||
#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
|
|
||||||
|
|
||||||
#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
|
|
||||||
#define IS_TRUECOL(x) (1 << 24 & (x))
|
|
||||||
|
|
||||||
enum glyph_attribute {
|
|
||||||
ATTR_NULL = 0,
|
|
||||||
ATTR_BOLD = 1 << 0,
|
|
||||||
ATTR_FAINT = 1 << 1,
|
|
||||||
ATTR_ITALIC = 1 << 2,
|
|
||||||
ATTR_UNDERLINE = 1 << 3,
|
|
||||||
ATTR_BLINK = 1 << 4,
|
|
||||||
ATTR_REVERSE = 1 << 5,
|
|
||||||
ATTR_INVISIBLE = 1 << 6,
|
|
||||||
ATTR_STRUCK = 1 << 7,
|
|
||||||
ATTR_WRAP = 1 << 8,
|
|
||||||
ATTR_WIDE = 1 << 9,
|
|
||||||
ATTR_WDUMMY = 1 << 10,
|
|
||||||
ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum selection_mode {
|
|
||||||
SEL_IDLE = 0,
|
|
||||||
SEL_EMPTY = 1,
|
|
||||||
SEL_READY = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum selection_type {
|
|
||||||
SEL_REGULAR = 1,
|
|
||||||
SEL_RECTANGULAR = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum selection_snap {
|
|
||||||
SNAP_WORD = 1,
|
|
||||||
SNAP_LINE = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef unsigned char uchar;
|
|
||||||
typedef unsigned int uint;
|
|
||||||
typedef unsigned long ulong;
|
|
||||||
typedef unsigned short ushort;
|
|
||||||
|
|
||||||
typedef uint_least32_t Rune;
|
|
||||||
|
|
||||||
#define Glyph Glyph_
|
|
||||||
typedef struct {
|
|
||||||
Rune u; /* character code */
|
|
||||||
ushort mode; /* attribute flags */
|
|
||||||
uint32_t fg; /* foreground */
|
|
||||||
uint32_t bg; /* background */
|
|
||||||
} Glyph;
|
|
||||||
|
|
||||||
typedef Glyph *Line;
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
int i;
|
|
||||||
uint ui;
|
|
||||||
float f;
|
|
||||||
const void *v;
|
|
||||||
const char *s;
|
|
||||||
} Arg;
|
|
||||||
|
|
||||||
void die(const char *, ...);
|
|
||||||
void redraw(void);
|
|
||||||
void draw(void);
|
|
||||||
|
|
||||||
void printscreen(const Arg *);
|
|
||||||
void printsel(const Arg *);
|
|
||||||
void sendbreak(const Arg *);
|
|
||||||
void toggleprinter(const Arg *);
|
|
||||||
|
|
||||||
int tattrset(int);
|
|
||||||
void tnew(int, int);
|
|
||||||
void tresize(int, int);
|
|
||||||
void tsetdirtattr(int);
|
|
||||||
void ttyhangup(void);
|
|
||||||
int ttynew(char *, char *, char *, char **);
|
|
||||||
size_t ttyread(void);
|
|
||||||
void ttyresize(int, int);
|
|
||||||
void ttywrite(const char *, size_t, int);
|
|
||||||
|
|
||||||
void resettitle(void);
|
|
||||||
|
|
||||||
void selclear(void);
|
|
||||||
void selinit(void);
|
|
||||||
void selstart(int, int, int);
|
|
||||||
void selextend(int, int, int, int);
|
|
||||||
int selected(int, int);
|
|
||||||
char *getsel(void);
|
|
||||||
|
|
||||||
size_t utf8encode(Rune, char *);
|
|
||||||
|
|
||||||
void *xmalloc(size_t);
|
|
||||||
void *xrealloc(void *, size_t);
|
|
||||||
char *xstrdup(char *);
|
|
||||||
|
|
||||||
int subprocwd(char *);
|
|
||||||
|
|
||||||
/* config.h globals */
|
|
||||||
extern char *utmp;
|
|
||||||
extern char *scroll;
|
|
||||||
extern char *stty_args;
|
|
||||||
extern char *vtiden;
|
|
||||||
extern wchar_t *worddelimiters;
|
|
||||||
extern int allowaltscreen;
|
|
||||||
extern int allowwindowops;
|
|
||||||
extern char *termname;
|
|
||||||
extern unsigned int tabspaces;
|
|
||||||
extern unsigned int defaultfg;
|
|
||||||
extern unsigned int defaultbg;
|
|
2080
st-0.8.4/x.c.orig
2080
st-0.8.4/x.c.orig
File diff suppressed because it is too large
Load Diff
@ -1,11 +0,0 @@
|
|||||||
--- x.c
|
|
||||||
+++ x.c
|
|
||||||
@@ -643,7 +643,7 @@ brelease(XEvent *e)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (e->xbutton.button == Button2)
|
|
||||||
+ if (e->xbutton.button == Button3)
|
|
||||||
selpaste(NULL);
|
|
||||||
else if (e->xbutton.button == Button1)
|
|
||||||
mousesel(e, 1);
|
|
Loading…
Reference in New Issue
Block a user