You are not logged in.

#1 2008-04-28 21:01:38

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

*Box-like menu with Dzen2. (UPDATED)

This thread will describe how to create a *box-like menu with dzen2, bash and a simple program to get the current cursor position. This thread is related to this thread: http://bbs.archlinux.org/viewtopic.php?id=45364 but I have decided to create a new thread for clarity.

[Edited out outdated stuff]

Now to the main script:

#!/bin/bash
# 
# Dzen2 App Launcher script box version by Rasmus Edgar.
# -tw = Width of titlebar, -w = Width of slavewindow,
# -l = length of slavewindow. Remember to adjust -l accordingly when adding 
# apps. ^pa(*) is for text/decoration alignment.
# 
#
#
# Menu script starts below.   
#
# Needed Applications:

AP1=firefox3
AP2=gimp
AP3=consonance
AP4=leafpad
AP5=pcmanfm
SM1=submenu

# Get cursor position:

XP=$(getcurpos | cut -c1-4)
YP=$(getcurpos | cut -c5-10)

# Decorations for the menu:

DC1=1x17
DC2=3x2
DC3=4x2
DC4=3x1
DC5=123x10
DC6=125x17

# Font:

FONT="-*-dina-medium-r-*-*-15-*-*-*-*-*-iso8859-1"

# Menu Title

TI="Dzen Menu"

# Colors:

FG1=#9ab8c2
FG2=#f57900
FG3=#D9A509
BG1=#43464f

# Icons:

IC1=~/dzen_bitmaps/xbm8x8/fox.xbm
IC2=~/dzen_bitmaps/xbm8x8/gimp.xbm
IC3=~/dzen_bitmaps/xbm8x8/note.xbm
IC4=~/dzen_bitmaps/xbm8x8/leaf.xbm
IC5=~/dzen_bitmaps/xbm8x8/pcman.xbm
SMI=~/dzen_bitmaps/xbm8x8/arrow.xbm

# Text piped to Dzen2

(echo "^ro(${DC6})^ib(1)^pa(30)$TI" ;echo -e "^fg(${FG1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC1})^fg(${FG1}) ${AP1} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC2})^fg(${FG1}) ${AP2} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC3})^fg(${FG1}) ${AP3} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC4})^fg(${FG1}) ${AP4} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC5})^fg(${FG1}) ${AP5} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${SMI})^fg(${FG1}) ${SM1} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^ro(${DC6})^ib(1)^pa(2)ver. 0.1")\
| (dzen2 -y "$YP" -x "$XP" -fn "$FONT" -bg "$BG1" -fg "$FG1" -l 7 -tw 125 -ta l -w 125 -m -p -e 'onstart=uncollapse;button1=menuexec;leaveslave=exit;button3=exit')

Save this script in your path as well, chmod +x it and adjust it to your liking (fonts, colors, icons(xbm and xpm), etc) - beware it may take a lot of your time. wink If you look at the script you will notice the "SM1" variable, this is just a copy of the above script with another file name (submenu), title, and different applications - a really simple way of creating a sub menu.

When you run it, you will notice that the menu will appear where the mouse pointer is located. You may wish to map the script to one of your mouse buttons with xbindkeys or something similar. My current .xbindkeysrc includes this:

#Dzen2 menu
"/home/edgar/bin/menuxy"
 b:2

Which launches the menu when the middle mouse button is pressed.

And the result looks like this:

xs.to sucks

I think this it might be a great supplement for Awesome or other tiling wm's.

~ Ashren

Last edited by Ashren (2010-03-30 21:10:53)

Offline

#2 2008-04-29 08:58:44

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: *Box-like menu with Dzen2. (UPDATED)

Great work, thanks Ashren! Since I'll be switching to a tiling wm in a couple of days, I will most definitely try this!


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#3 2008-04-29 18:27:28

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: *Box-like menu with Dzen2. (UPDATED)

You're welcome and thanks! Don't hesitate to ask here if you have any questions.

Btw. The icons for the menu can be found here: http://dzen.geekmode.org/dwiki/doku.php … icon-packs

I created a couple myself with xpaint which is dead easy, but confined to 8x8 pixels.

Offline

#4 2008-04-29 20:12:32

zodmaner
Member
Registered: 2007-07-11
Posts: 653

Re: *Box-like menu with Dzen2. (UPDATED)

Very nice guide indeed. Thanks for taking your time to write this, Ashren. smile

Offline

#5 2008-05-02 19:42:44

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: *Box-like menu with Dzen2. (UPDATED)

Hi,

I was not really satisfied with the dirty getcurpos hack, so looked into alternatives. The linux command 'cut' proved to be the solution, so here's the updated script:

#!/bin/bash
# 
# Dzen2 App Launcher script box version by Rasmus Edgar.
# -tw = Width of titlebar, -w = Width of slavewindow,
# -l = length of slavewindow. Remember to adjust -l accordingly when adding 
# apps. ^pa(*) is for text/decoration alignment.
# 
#
#
# Menu script starts below.   
#
# Needed Applications:

AP1=firefox3
AP2=gimp
AP3=consonance
AP4=leafpad
AP5=pcmanfm
SM1=submenu

# Get cursor position:

XP=$(getcurpos | cut -c1-4)
YP=$(getcurpos | cut -c5-10)

# Decorations for the menu:

DC1=1x17
DC2=3x2
DC3=4x2
DC4=3x1
DC5=123x10
DC6=125x17

# Font:

FONT="-*-dina-medium-r-*-*-15-*-*-*-*-*-iso8859-1"

# Menu Title

TI="Dzen Menu"

# Colors:

FG1=#9ab8c2
FG2=#f57900
FG3=#D9A509
BG1=#43464f

# Icons:

IC1=~/dzen_bitmaps/xbm8x8/fox.xbm
IC2=~/dzen_bitmaps/xbm8x8/gimp.xbm
IC3=~/dzen_bitmaps/xbm8x8/note.xbm
IC4=~/dzen_bitmaps/xbm8x8/leaf.xbm
IC5=~/dzen_bitmaps/xbm8x8/pcman.xbm
SMI=~/dzen_bitmaps/xbm8x8/arrow.xbm

# Text piped to Dzen2

(echo "^ro(${DC6})^ib(1)^pa(30)$TI" ;echo -e "^fg(${FG1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC1})^fg(${FG1}) ${AP1} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC2})^fg(${FG1}) ${AP2} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC3})^fg(${FG1}) ${AP3} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC4})^fg(${FG1}) ${AP4} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${IC5})^fg(${FG1}) ${AP5} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^r(${DC1})^r(${DC2})^r(${DC3}) ^fg(${FG3})^i(${SMI})^fg(${FG1}) ${SM1} ^pa(117)^r(${DC3})^r(${DC2})^r(${DC1})\
\n^ro(${DC6})^ib(1)^pa(2)ver. 0.1")\
| (dzen2 -y "$YP" -x "$XP" -fn "$FONT" -bg "$BG1" -fg "$FG1" -l 7 -tw 125 -ta l -w 125 -m -p -e 'onstart=uncollapse;button1=menuexec;leaveslave=exit;button3=exit')

Created a couple of PKGBUILD's as well:

Menuxy's PKGBUILD

# Contributor: ashren
pkgname=menuxy
pkgver=0.1
pkgrel=1
pkgdesc="Boxlike menu for Dzen2"
arch=(i686)
url="http://code.google.com/p/menuxy/"
license=('GPL')
depends=()
source=(http://menuxy.googlecode.com/files/$pkgname)
noextract=()
md5sums=('')

build() {

install -m 755 -D $startdir/menuxy $startdir/pkg/usr/bin/menuxy


}

# vim:set ts=2 sw=2 et:

getcurpos's PKGBUILD:

# Contributor: ashren <youremail@domain.com>
pkgname=getcurpos
pkgver=0.1
pkgrel=1
pkgdesc="small tool to get cursor position"
arch=(i686)
url="http://dzen.geekmode.org/dwiki/doku.php?id=misc:xget-mouse-position"
license=('GPL')
depends=()
source=(http://dzen.geekmode.org/dwl/misc/$pkgname.c)
noextract=()
md5sums=('')

build() {

gcc -Wall -lX11 $startdir/getcurpos.c -o $startdir/getcurpos
install -m 755 -D $startdir/getcurpos $startdir/pkg/usr/bin/getcurpos


}

# vim:set ts=2 sw=2 et:

Combine my 8x8icons, which you get here: http://menuxy.googlecode.com/files/8x8icons.tar.gz with sm4tik's here: http://koti.24.fi/sm4tik/shared/xbm8x8-0.1.tar.gz

~ ashren

Last edited by Ashren (2009-06-18 12:55:34)

Offline

#6 2008-07-03 03:35:23

leo2501
Member
From: Buenos Aires, Argentina
Registered: 2007-07-07
Posts: 658

Re: *Box-like menu with Dzen2. (UPDATED)

hi! i can make it work, but when clicked on an item nothing happends sad


Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery

Offline

#7 2008-07-03 07:26:24

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: *Box-like menu with Dzen2. (UPDATED)

I will try it out on a fresh install as soon as possible and see if I can replicate your problem.

EDIT:

Are you using the latest script?

Last edited by Ashren (2008-07-03 19:21:22)

Offline

#8 2008-07-07 20:06:43

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: *Box-like menu with Dzen2. (UPDATED)

leo2501: I have an idea that might explain why your menu does not work. Did you change the names of applications, or use capitol letters i.e. "Firefox"? This will not work since the menu entries has to be same as the executables.

Offline

#9 2008-07-08 09:04:30

robmaloy
Member
From: Germany
Registered: 2008-05-14
Posts: 263

Re: *Box-like menu with Dzen2. (UPDATED)

i modified your script so it "parses" a ~/.menuxy which contains:
application,/path/to/icon

+ i changed "button1=menuexec" to "button1=menuexec,exit" so the menu gets closed once you click


http://rob.kingofnerds.net/menuxy


☃ Snowman ☃

Offline

#10 2008-07-16 15:50:11

gotmor
Member
From: Germany
Registered: 2007-09-03
Posts: 84
Website

Re: *Box-like menu with Dzen2. (UPDATED)

No submenus on this one, though they could be integrated:

   http://dzen.geekmode.org/dwiki/doku.php?id=dzen:dz9menu

Note this script makes use of the new "menuprint_noparse" action, so you will need to use the SVN version of dzen:

svn checkout http://dzen.googlecode.com/svn/trunk/ dzen

Offline

#11 2009-05-21 01:37:52

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: *Box-like menu with Dzen2. (UPDATED)

Sorry to bump an oldish thread, but I made this tiny utility that I'm sure would be useful to anyone using this. It basically watches for right clicking on the root window, and if a right click is detected it launches the script you pass as an argument with the X and Y position of the cursor. I'm about to try it out with dz9menu, should make a winning combination I think smile

EDIT: Just noticed it captures right click for everything so I need a way of ignoring it and passing it on, anyone know how to do this?

EDIT2: Figured it out, fixed the code smile

Compile with

gcc -Wall -Wextra -o rootgrab main.c -lX11
/*
 * Run <path> on root window right click
 * By HashBox
 */

#include <X11/Xlib.h>

#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv)
{
    Display *dpy;
    XEvent ev;

    if (argc < 2) {
        fprintf(stderr, "Usage: %s <path>\n", argv[0]);
        return 1;
    }

    if (!(dpy = XOpenDisplay(NULL))) {
        fprintf(stderr, "Could not open display %s", getenv("DISPLAY"));
    }

    XGrabButton(dpy, 3, 0, DefaultRootWindow(dpy), True, ButtonPressMask, GrabModeSync, GrabModeAsync, None, None);

    for (;;) {
        XNextEvent(dpy, &ev);

        if (ev.type == ButtonPress) {
            if (ev.xbutton.subwindow == None) {
                char buff[256];
                sprintf(buff, "%s %i %i &", argv[1], ev.xbutton.x_root, ev.xbutton.y_root);
                system(buff);
            }

            XAllowEvents(dpy, ReplayPointer, CurrentTime);
        }
    }

    XCloseDisplay(dpy);

    return 0;
}

Last edited by HashBox (2009-05-21 03:23:25)

Offline

Board footer

Powered by FluxBB