You are not logged in.

#901 2012-10-25 09:39:51

ivoarch
Member
From: the six feet under the ground
Registered: 2011-03-31
Posts: 436

Re: DWM Hackers Unite! Share (or request) dwm patches.

Separator between tag names can be something like..

char separator[] = "|"; 
drawtext(separator, dc.colors[1]); 

I love GnuEmacs, GnuScreen, ratpoison, and conkeror.
Github )||( Weblog

Offline

#902 2012-10-25 09:47:37

Unia
Member
From: The Netherlands
Registered: 2010-03-30
Posts: 2,472
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

ivoarch wrote:

Separator between tag names can be something like..

char separator[] = "|"; 
drawtext(separator, dc.colors[1]); 

Dammit so simple! big_smile I always try edit an existing string.... Thanks!

EDIT: Do you also now how I can add a bit of spacing in front of the layout symbol? Right now I'm doing this in config.h but I would like to see if this is possible in dwm.c too.

EDIT2: Oke, I came up with this:

--- dwm.c.orig  2012-10-25 12:11:21.783482614 +0200
+++ b/dwm-6.0/dwm.c 2012-10-25 12:13:55.940177730 +0200
@@ -854,6 +854,7 @@
         dc.w = TEXTW(tags[i].name);
        col = dc.colors[ (m->tagset[m->seltags] & 1 << i) ? 1 : (urg & 1 << i ? 2:(occ & 1 << i ? 3:0)) ];
         drawtext(tags[i].name, col, True);
+       drawtext(separator, dc.colors[1], True);
        dc.x += dc.w - SPACING;
    }
    dc.w = blw = TEXTW(m->ltsymbol);

Now there's two issues:
1. I only see the separators, not the tag names. I guess this is because I now use two drawtext functions in the same for.
2. I also get a separator in front of my first tag and after my last. How can I make the separator appear only in between the tag names? (If that's even possible at all tongue)

Last edited by Unia (2012-10-25 10:56:21)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#903 2012-10-25 10:45:02

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,966
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

--- dwm.c.orig  2012-10-25 12:11:21.783482614 +0200
+++ b/dwm-6.0/dwm.c 2012-10-25 12:13:55.940177730 +0200
@@ -854,6 +854,7 @@
         dc.w = TEXTW(tags[i].name);
        col = dc.colors[ (m->tagset[m->seltags] & 1 << i) ? 1 : (urg & 1 << i ? 2:(occ & 1 << i ? 3:0)) ];
         drawtext(tags[i].name, col, True);
+       dc.x += dc.w - SPACING;
+        dc.w = TEXTW(separator);
+       drawtext(separator, dc.colors[1], True);
        dc.x += dc.w - SPACING;
    }
    dc.w = blw = TEXTW(m->ltsymbol);

InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Online

#904 2012-10-25 10:51:22

Unia
Member
From: The Netherlands
Registered: 2010-03-30
Posts: 2,472
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Could you also please explain what you did there? What exactly does TEXTW do?


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#905 2012-10-25 10:56:46

ivoarch
Member
From: the six feet under the ground
Registered: 2011-03-31
Posts: 436

Re: DWM Hackers Unite! Share (or request) dwm patches.


I love GnuEmacs, GnuScreen, ratpoison, and conkeror.
Github )||( Weblog

Offline

#906 2012-10-25 11:05:47

Unia
Member
From: The Netherlands
Registered: 2010-03-30
Posts: 2,472
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

^ Thanks, will look into it smile


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#907 2012-10-25 12:28:25

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,966
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

TEXTW is a macro* that calculates how much horizontal space (in pixels) a given string will take up on the screen.

Dwm saves this value to dc.w (w=width) and uses this value to increment dc.x (x coordinate) for the next string that needs to be printed to the screen.  The Xlib drawstring functions do not keep track of how much text has previously been written to the screen, so the program must keep track of at which x-coordinate the next string should be printed.

*note: one of my minor 'gripes' about dwm is that it makes extensive use of macros and it's own functions to do fairly simple tasks.  In the end this makes reading the code harder as you have to jump around to see what the code is actually doing.  In this case you can find the TEXTW macro definition near the top of dwm.c.

Edit: if you didn't keep track of these x-coordinates properly, each string you draw to the screen would just overwrite the previous one.  In your initial patch, you kept the original incrementing of the x coordinate that dwm had when it printed the tags, but you didn't add another increment to account for the separator.

Last edited by Trilby (2012-10-25 12:29:58)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Online

#908 2012-10-25 12:41:49

Unia
Member
From: The Netherlands
Registered: 2010-03-30
Posts: 2,472
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Man, I hope I'm going to be as fluent in this once as you are! Thanks for explaining and helping, both Trilby and Ivo smile


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#909 2012-10-25 14:31:04

Unia
Member
From: The Netherlands
Registered: 2010-03-30
Posts: 2,472
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Just a thought: how much work would it be to get the statusbar transparent? I messed around a bit with an old patch found on suckless to get clients transparent but I noticed the bar is a whole different thing than a client (which I confirmed with transset-df from [community]). I guess I'd need to modify the color strings so I can set transparent colors?

In case anyone's interested, this is what I made up initially: https://gist.github.com/3952869 . It's far from completed though and spits a lot of errors.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#910 2012-10-26 01:10:27

Crunch
Member
From: -+-
Registered: 2011-02-17
Posts: 56

Re: DWM Hackers Unite! Share (or request) dwm patches.

Only problem I've found with the separator above is that it doesn't keep mouse clicks aligned properly. Not that I use the mouse much, but just to note the few times I have since it's been posted hasn't worked out too great. Seems to keep the clicking area where the tags would be without the extra spacing.


Registered Linux user #536591.

Offline

#911 2012-10-26 01:22:48

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,966
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

A transparent status bar should be pretty simple.

You could go for "true" transparency which would require a compositing manager, but pseudo transparency would be easier[1] and should be fine for a status bar as there would never be anything underneath it.

To do this, all you would need is to create a new pixmap or drawable the same size as the status bar window.  When dwm starts up a single call to XCopyArea to copy the root window contents to the new pixmap, then each time the bar is redrawn another XCopyArea to copy the new pixmap to the status bar window.

You might want to also have a XCopyArea to copy the root window into the new pixmap whenever the root window is changed so it would update if you changed your root window 'wallpaper'.

All in all it would only be 5 or 6 lines of code.

EDIT: I just confirmed these steps work and provide a pseudotransparent statusbar.  It required five lines to be added to dwm.c and 2 lines were removed.  I'll shoot for the "teach a man to fish" strategy and not ruin all the fun of figuring out how to do this, now that I confirmed these steps do work.  If you want feedback or more pointers, let me know.  Or if you really the fun ruined and just want the "answer" let me know - but I'd encourage you to try to implement it yourself.

I can recommend checking out some pages on the Tronche guide, like this one: http://tronche.com/gui/x/xlib/graphics/XCopyArea.html

[1] Actually true transparency might require even fewer code changes, but the solution for pseudo-transparency more readily came to my mind as I have not done much with true transparency in my own coding.

Last edited by Trilby (2012-10-26 01:58:25)


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Online

#912 2012-10-26 09:59:54

Unia
Member
From: The Netherlands
Registered: 2010-03-30
Posts: 2,472
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Crunch wrote:

Only problem I've found with the separator above is that it doesn't keep mouse clicks aligned properly. Not that I use the mouse much, but just to note the few times I have since it's been posted hasn't worked out too great. Seems to keep the clicking area where the tags would be without the extra spacing.

I guess that is because the TEXTW macro doesn't "know about" the SPACING we use. I don't know if that's fixable?

Trilby wrote:

A transparent status bar should be pretty simple.

...

EDIT: I just confirmed these steps work and provide a pseudotransparent statusbar.  It required five lines to be added to dwm.c and 2 lines were removed.  I'll shoot for the "teach a man to fish" strategy and not ruin all the fun of figuring out how to do this, now that I confirmed these steps do work.  If you want feedback or more pointers, let me know.  Or if you really the fun ruined and just want the "answer" let me know - but I'd encourage you to try to implement it yourself.

I'll have a go add it! I've send you an email on this as I don't want to spam this thread.

Last edited by Unia (2012-10-26 10:22:18)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#913 2012-10-27 22:34:27

Crunch
Member
From: -+-
Registered: 2011-02-17
Posts: 56

Re: DWM Hackers Unite! Share (or request) dwm patches.

Ok, after messing around with the provided patch enough I decided the mouse click problem was a problem for me ( I guess I use it more than I realise still ). So I took a step back, and decided to try the bar border patch provided a couple pages back and use that to surround each tag. Doesn't offset them at all so it doesn't effect the mouse click area.

        }
 +       XSetForeground(dpy, dc.gc, dc.colors[8][ColBorder]);
 +       XDrawRectangle(dpy, dc.drawable, dc.gc, dc.x, 0, 0, bh);
        dc.x += dc.w;
    }
    dc.w = blw = TEXTW(m->ltsymbol);

Only thing it doesn't do is it doesn't let you select the type of separator as... it's just a box.


Preview:
http://ompldr.org/vZzFyZw
tZzFyZw

Last edited by Crunch (2012-10-27 23:32:46)


Registered Linux user #536591.

Offline

#914 2012-10-28 15:44:16

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: DWM Hackers Unite! Share (or request) dwm patches.

Not sure if a patch is needed for this, but i'm playing around with Compton and i was wondering if it's possible to make the statusbar always have the highest z-index, so that it's shadow falls over any windows occupying the desktop space?


ᶘ ᵒᴥᵒᶅ

Offline

#915 2012-10-28 16:11:47

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,966
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

litemotiv, I suspect that all that would take is a call to XRaiseWindow everytime a window is changed.  The most "aggressive" place to put this would be in the configurenotify event handler.  Putting it in the drawbar function would work for a majority of situations.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Online

#916 2012-10-28 17:22:18

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: DWM Hackers Unite! Share (or request) dwm patches.

Thanks Trilby, i'll experiment a bit with that. smile


ᶘ ᵒᴥᵒᶅ

Offline

#917 2012-10-31 12:55:20

rix
Member
Registered: 2012-07-25
Posts: 221

Re: DWM Hackers Unite! Share (or request) dwm patches.

Sorry but I can't get it working properly.
Suggestions?

Thanks.

Offline

#918 2012-10-31 16:51:34

jasonwryan
Forum & Wiki Admin
From: .nz
Registered: 2009-05-09
Posts: 19,009
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Please open a new thread, and include some relevant information, "can't get it working properly" doesn't really help anyone...


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Online

#919 2012-10-31 17:21:52

rix
Member
Registered: 2012-07-25
Posts: 221

Re: DWM Hackers Unite! Share (or request) dwm patches.

Jason, sorry for the ot, but please notice that I've linked my previous post for the purpose of including such relevant infos. I know that "can't get it working properly" doesn't help anyone.
And also I don't think opening a new thread is needing in this case. Btw as you want.

Offline

#920 2012-11-02 12:14:31

isnull
Member
Registered: 2012-10-30
Posts: 17

Re: DWM Hackers Unite! Share (or request) dwm patches.

Hi all, I'm trying to get i3lock to enable on suspend with systemd. I tried this in /usr/lib/systemd/system-sleep/example.sh:

#!/bin/sh
case $1/$2 in
  pre/*)
    echo > /var/log/test
    echo "Going to $2..." >> /var/log/test
    DISPLAY=:0 su -c i3lock jpic
    ;;  
  post/*)
    echo "Waking up from $2..." >> /var/log/test
    ;;  
esac

It shows a white screen when waking up for a second and then I'm in dwm again, without having to type my password.

Any idea ?

Offline

#921 2012-11-02 12:33:22

Unia
Member
From: The Netherlands
Registered: 2010-03-30
Posts: 2,472
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

This has nothing to do with hacking DWM. I suggest you start a new thread over at Applications & Desktop Environments


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#922 2012-11-02 15:25:38

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,966
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Even better than starting a new thread would be to search for the old ones that addressed that exact question - and IIRC have a solution.  I don't use that program, so I don't know details, but I do know there were threads on that.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Online

#923 2012-11-03 10:19:14

ivoarch
Member
From: the six feet under the ground
Registered: 2011-03-31
Posts: 436

Re: DWM Hackers Unite! Share (or request) dwm patches.

I created few patches for Dwm. 
Inspiration from: Ratpoison wm
=>

Banish.diff - Warps the X mouse pointer to the bottom right corner.

Prefix-key.diff - Ratpoison/StumpWM style (using prefix key).
- Autor: matt mooney
- Modified: ivo

Mousemove.diff - Move the mouse cursor with the keyboard.
- Dependencies: xdotool


I love GnuEmacs, GnuScreen, ratpoison, and conkeror.
Github )||( Weblog

Offline

#924 2012-11-05 22:44:40

Mad_Hatter93
Member
Registered: 2012-06-30
Posts: 19

Re: DWM Hackers Unite! Share (or request) dwm patches.

So I've been looking around for a while, and haven't yet found a statuscolors patch that will work with vanilla dwm 6.1. Has anyone had any luck with this? I tried jasonwryan's patch, and just for kicks dwm's 5.9 patch, but both fail on most hunks

Offline

#925 2012-11-05 23:28:42

mkaito
Member
From: Spain
Registered: 2010-06-12
Posts: 121
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

ivoarch wrote:

Prefix-key.diff - Ratpoison/StumpWM style (using prefix key).
- Autor: matt mooney
- Modified: ivo

Any chance you expand a little about what this does and how to use it?


Fear me! I have root! Sometimes...

Offline

Board footer

Powered by FluxBB