Skip to content

Commit

Permalink
Add my config
Browse files Browse the repository at this point in the history
  • Loading branch information
mintycube committed Jun 24, 2024
1 parent 316de88 commit 0238bdf
Show file tree
Hide file tree
Showing 5 changed files with 315 additions and 96 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
slock
*.o
dwm
config.h
patches.h
94 changes: 3 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,69 +1,11 @@
Similar to [dwm-flexipatch](https://github.com/bakkeby/dwm-flexipatch) this slock 1.5 (a34d8fb,
2023-10-06) project has a different take on patching. It uses preprocessor directives to decide
whether or not to include a patch during build time. Essentially this means that this build, for
better or worse, contains both the patched _and_ the original code. The aim being that you can
select which patches to include and the build will contain that code and nothing more.
<h1 align="center"> slock</h1>

For example to include the `capscolor` patch then you would only need to flip this setting from 0
to 1 in [patches.h](https://github.com/bakkeby/slock-flexipatch/blob/master/patches.h):
```c
#define CAPSCOLOR_PATCH 1
```
Once you have found out what works for you and what doesn't then you should be in a better position
to choose patches should you want to start patching from scratch.
Alternatively if you have found the patches you want, but don't want the rest of the flexipatch
entanglement on your plate then you may want to have a look at
[flexipatch-finalizer](https://github.com/bakkeby/flexipatch-finalizer); a custom pre-processor
tool that removes all the unused flexipatch code leaving you with a build that contains the patches
you selected.
Refer to [https://tools.suckless.org/slock/](https://tools.suckless.org/slock/) for details on the
slock tool, how to install it and how it works.
---
### Changelog:
2022-03-28 - Added the background image patch
2021-09-13 - Added the dwm logo patch
2021-09-09 - Added the auto-timeout, failure-command and secret-password patches
2021-06-08 - Added the color message patch
2020-08-03 - Added alpha, keypress_feedback and blur_pixelated_screen patches
2019-11-27 - Added xresources patch
2019-10-17 - Added capscolor, control clear, dpms, mediakeys, message, pam auth, quickcancel patches
2019-10-16 - Introduced [flexipatch-finalizer](https://github.com/bakkeby/flexipatch-finalizer)
### Patches included:
- [alpha](https://github.com/khuedoan/slock)
- enables transparency for slock
- intended to be combined with a compositor that can blur the transparent background
- [auto-timeout](https://tools.suckless.org/slock/patches/auto-timeout/)
- allows for a command to be executed after a specified time of inactivity
- [background_image](https://tools.suckless.org/slock/patches/background-image/)
- sets the lockscreen picture to a background image
Personal build of slock generated using [slock-flexipatch](https://github.com/bakkeby/slock-flexipatch.git)
### Patches applied:

- [blur_pixelated_screen](https://tools.suckless.org/slock/patches/blur-pixelated-screen/)
- sets the lockscreen picture to a blured or pixelated screenshot

- [capscolor](https://tools.suckless.org/slock/patches/capscolor/)
- adds an additional color to indicate the state of Caps Lock
- [color-message](https://tools.suckless.org/slock/patches/colormessage/)
- based on the message patch this patch lets you add a message to your lock screen using
24-bit color ANSI escape codes
- [control-clear](https://tools.suckless.org/slock/patches/control-clear/)
- with this patch slock will no longer change to the failure color if a control key is pressed
while the buffer is empty
Expand All @@ -79,39 +21,9 @@ slock tool, how to install it and how it works.
- [dwmlogo](https://tools.suckless.org/slock/patches/dwmlogo/)
- draws the dwm logo which changes color based on the state

- [failure-command](https://tools.suckless.org/slock/patches/failure-command/)
- allows for a command to be run after a specified number of incorrect attempts
- [keypress_feedback](https://tools.suckless.org/slock/patches/keypress-feedback/)
- draws random blocks on the screen to display keypress feedback
- [mediakeys](https://tools.suckless.org/slock/patches/mediakeys/)
- allows media keys to be used while the screen is locked, e.g. adjust volume or skip to the
next song without having to unlock the screen first

- [message](https://tools.suckless.org/slock/patches/message/)
- this patch lets you add a custom message to your lock screen
- [pam-auth](https://tools.suckless.org/slock/patches/pam_auth/)
- replaces shadow support with PAM authentication support
- [quickcancel](https://tools.suckless.org/slock/patches/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 can be useful if you forgot to disable xautolock during an activity that requires no
input (e.g. reading text, watching video, etc.)
- [secret-password](https://tools.suckless.org/slock/patches/secret-password/)
- allows for commands to be executed when the user enters special passwords
- [terminalkeys](https://tools.suckless.org/slock/patches/terminalkeys/)
- adds key commands that are commonly used in terminal applications (in particular the login
prompt)
- [unlockscreen](https://tools.suckless.org/slock/patches/unlock_screen/)
- this patch keeps the screen unlocked, but keeps the input locked
- that is, the screen is not affected by slock, but users will not be able to interact with
the X session unless they enter the correct password
- [xresources](https://tools.suckless.org/slock/patches/xresources/)
- this patch adds the ability to get colors via Xresources
164 changes: 164 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/* user and group to drop privileges to */
static const char *user = "nobody";
static const char *group = "nobody"; // use "nobody" for arch

static const char *colorname[NUMCOLS] = {
#if DWM_LOGO_PATCH && !BLUR_PIXELATED_SCREEN_PATCH
[BACKGROUND] = "#2d2d2d", /* after initialization */
#endif // DWM_LOGO_PATCH
[INIT] = "black", /* after initialization */
[INPUT] = "#005577", /* during input */
[FAILED] = "#CC3333", /* wrong password */
#if CAPSCOLOR_PATCH
[CAPS] = "red", /* CapsLock on */
#endif // CAPSCOLOR_PATCH
#if PAMAUTH_PATCH
[PAM] = "#9400D3", /* waiting for PAM */
#endif // PAMAUTH_PATCH
#if KEYPRESS_FEEDBACK_PATCH
[BLOCKS] = "#ffffff", /* key feedback block */
#endif // KEYPRESS_FEEDBACK_PATCH
};

#if MESSAGE_PATCH || COLOR_MESSAGE_PATCH
/* 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";
#endif // MESSAGE_PATCH | COLOR_MESSAGE_PATCH

#if BACKGROUND_IMAGE_PATCH
/* Background image path, should be available to the user above */
static const char * background_image = "";
#endif // BACKGROUND_IMAGE_PATCH

#if DWM_LOGO_PATCH
/* insert grid pattern with scale 1:1, the size can be changed with logosize */
static const int logosize = 8;
static const int logow = 12; /* grid width and height for right center alignment*/
static const int logoh = 6;

static XRectangle rectangles[] = {
/* x y w h */
{ 0, 3, 1, 3 },
{ 1, 3, 2, 1 },
{ 0, 5, 8, 1 },
{ 3, 0, 1, 5 },
{ 5, 3, 1, 2 },
{ 7, 3, 1, 2 },
{ 8, 3, 4, 1 },
{ 9, 4, 1, 2 },
{ 11, 4, 1, 2 },
};
#endif // DWM_LOGO_PATCH

#if XRESOURCES_PATCH
/*
* Xresources preferences to load at startup
*/
ResourcePref resources[] = {
#if DWM_LOGO_PATCH && !BLUR_PIXELATED_SCREEN_PATCH
{ "background", STRING, &colorname[BACKGROUND] },
#endif //DWM_LOGO_PATCH
#if BACKGROUND_IMAGE_PATCH
{ "bg_image", STRING, &background_image },
#endif // BACKGROUND_IMAGE_PATCH
{ "locked", STRING, &colorname[INIT] },
{ "input", STRING, &colorname[INPUT] },
{ "failed", STRING, &colorname[FAILED] },
#if CAPSCOLOR_PATCH
{ "capslock", STRING, &colorname[CAPS] },
#endif // CAPSCOLOR_PATCH
#if PAMAUTH_PATCH
{ "pamauth", STRING, &colorname[PAM] },
#endif // PAMAUTH_PATCH
#if MESSAGE_PATCH || COLOR_MESSAGE_PATCH
{ "message", STRING, &message },
{ "text_color", STRING, &text_color },
{ "font_name", STRING, &font_name },
#endif // MESSAGE_PATCH | COLOR_MESSAGE_PATCH
};
#endif // XRESOURCES_PATCH

#if ALPHA_PATCH
/* lock screen opacity */
static const float alpha = 0.9;
#endif // ALPHA_PATCH

/* treat a cleared input like a wrong password (color) */
static const int failonclear = 1;

#if AUTO_TIMEOUT_PATCH
/* length of time (seconds) until */
static const int timeoffset = 60;

/* should [command] be run only once? */
static const int runonce = 0;

/* command to be run after [time] has passed */
static const char *command = "doas poweroff";
#endif // AUTO_TIMEOUT_PATCH

#if FAILURE_COMMAND_PATCH
/* number of failed password attempts until failcommand is executed.
Set to 0 to disable */
static const int failcount = 0;

/* command to be executed after [failcount] failed password attempts */
static const char *failcommand = "shutdown";
#endif // FAILURE_COMMAND_PATCH

#if SECRET_PASSWORD_PATCH
static const secretpass scom[] = {
/* Password command */
{ "shutdown", "doas poweroff"},
};
#endif // SECRET_PASSWORD_PATCH

#if BLUR_PIXELATED_SCREEN_PATCH
/* Enable blur */
#define BLUR
/* Set blur radius */
static const int blurRadius = 5;
/* Enable Pixelation */
//#define PIXELATION
/* Set pixelation radius */
static const int pixelSize = 10;
#endif // BLUR_PIXELATED_SCREEN_PATCH

#if CONTROLCLEAR_PATCH
/* allow control key to trigger fail on clear */
static const int controlkeyclear = 1;
#endif // CONTROLCLEAR_PATCH

#if DPMS_PATCH
/* time in seconds before the monitor shuts down */
static const int monitortime = 5;
#endif // DPMS_PATCH

#if KEYPRESS_FEEDBACK_PATCH
static short int blocks_enabled = 1; // 0 = don't show blocks
static const int blocks_width = 0; // 0 = full width
static const int blocks_height = 16;

// position
static const int blocks_x = 0;
static const int blocks_y = 0;

// Number of blocks
static const int blocks_count = 10;
#endif // KEYPRESS_FEEDBACK_PATCH

#if PAMAUTH_PATCH
/* PAM service that's used for authentication */
static const char* pam_service = "login";
#endif // PAMAUTH_PATCH

#if QUICKCANCEL_PATCH
/* time in seconds to cancel lock with mouse movement */
static const int timetocancel = 4;
#endif // QUICKCANCEL_PATCH
6 changes: 3 additions & 3 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ X11LIB = /usr/X11R6/lib
#NETBSD=-D_NETBSD_SOURCE

# Uncomment for message patch / MESSAGE_PATCH / COLORMESSAGE_PATCH / DWM_LOGO_PATCH
#XINERAMA=-lXinerama
#XINERAMAFLAGS = -DXINERAMA
XINERAMA=-lXinerama
XINERAMAFLAGS = -DXINERAMA

# Uncomment for pam auth patch / PAMAUTH_PATCH
#PAM=-lpam

# Uncomment for blur pixelated screen and background image patches / BLUR_PIXELATED_SCREEN_PATCH, BACKGROUND_IMAGE_PATCH
#IMLIB=-lImlib2
IMLIB=-lImlib2

# includes and libs
INCS = -I. -I/usr/include -I${X11INC}
Expand Down
Loading

0 comments on commit 0238bdf

Please sign in to comment.