Howto: Lock Your Screen in dwm with WindowsKey+L

Posted 918 days ago - Debian, Security

A couple months ago I gave up all those fancy buttons, panels, widgets, icons, and other miscellaneous crap that make using a computer annoying, for a more simplistic approach. The dynamic window manager from suckless provides anything the casual web surfer or hardware design engineer could ever want and nothing more; exactly what a window manager should do. If you're reading this article chances are you already know this, so let's cut the crap.

The traditional Windows XP/2003 method of locking your workstation is pretty slick, just press WindowKey+L and you're good to go. But how do we bring that functionality to DWM? Easy...

Open your config.h:

q9550:/home/sysop/.dwm/dwm-5.6.1# vi config.h

Find this section:

/* key definitions */
#define MODKEY Mod1Mask
#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} },

Modify to look like this:

/* key definitions */
#define MODKEY Mod1Mask
#define WINKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
{ MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
{ WINKEY,                       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} },

Next, find the commands section, and append:

static const char *slock[]    = { "slock", NULL };

Then make your way to the keys section and make it look like this:

static Key keys[] = {
/* modifier                     key        function        argument */
{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
{ MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
{ WINKEY,                       XK_l,      spawn,          {.v = slock } },
{ MODKEY,                       XK_b,      togglebar,      {0} },
etc... 

Save your changes and quit, then recompile dwm.

q9550:/home/sysop/.dwm/dwm-5.6.1# make clean install

Now, if you haven't already, download, extract, and install slock:

http://tools.suckless.org/slock

Finally, ModKey + Shift + Q to shut down dwm gracefully, then startx to fire it back up. Try locking your screen by pressing WindowKey (Mod4) + L. If the screen goes black, you're good to go. If not, you did something wrong, or my directions suck. Either way, let me know and we'll figure it out..

Word Count: 401

Tags: , , , ,

Click Here to Submit a Comment

Permalink / Last Modified:

Support Nullamatix.com:

See Also:

  • 04/11/2010 -- Howto: XCache in a Lighttpd Chroot on Debian
    Excerpt: "Whether you're pressed for resources on a virtual/dedicated server, or simply looking for ways to improve web application performance, XCache is guaranteed to produce the desired result. Within minutes of installing XCache: page load times were cut in half, ..."
  • 08/31/2009 -- Howto: Insert Bash Command Output Into MySQL
    Excerpt: "A BlogStorm reader emailed me today, Hello, I am replying to your post on http://www.blogstorm.co.uk/how-to-scrape-pages-with-coldfusion/ Wanted to see your experience in page scraping, may need your help on a project. HOw much did you do beyond the ..."
  • 02/25/2010 -- DWM on Wikipedia Marked For Deletion
    Excerpt: "Anselm, the "inventor of dwm" shared this information with the suckless mailing list yesterday. Apparently, Wikipedia has flagged the dwm (dynamic window manager from suckless.org) article for deletion. Anselm says he's neutral and shared his thoughts on the ..."
  • 08/14/2009 -- Howto: Tail Lighttpd Logs with Style using Sed
    Excerpt: "Although extremely useful, http server access logs are a mess in their raw form. If you're interested in watching your http server logs in real time with formatting rules and pretty colors, this post is for you. Teh Scr1pt Create a new file to put the l33t ..."

0 Comments

[ RSS feed | Trackback URI | Leave a Comment ]

Leave a Comment

Comments are moderated prior to showing up. If your comment does not show up immediately, please do not attempt to resubmit. If you're redirected to the original post after pressing "Add Comment", your comment was successfully entered into the moderation queue.

Trackback Responses to This Post:

  • No Trackbacks, yet. Help Nullamatix.com by Linking to This Post.