You are not logged in.

#176 2009-02-14 15:14:36

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

Re: dzen & xmobar Hacking Thread

Thanks Paul-S. Here is another little tweak to change layout with a left click simply add the following to your xmonad.hs in the (my)LogHook section:

      fill h i = "^p(" ++ show i ++ ")^ca(1,wss)" ++ h ++ "^p(" ++ show i ++ ")^ca()"

And create wss script containing:

xdotool key <prefmodkey>+space

Does anyone know if there are ways to send commands to XMonad without xdotool?

Thanks gotmor for providing these new features.

Offline

#177 2009-02-14 17:34:01

ST.x
Member
From: Sydney, Australia
Registered: 2008-01-25
Posts: 363
Website

Re: dzen & xmobar Hacking Thread

Ashren wrote:

Thanks Paul-S. Here is another little tweak to change layout with a left click simply add the following to your xmonad.hs in the (my)LogHook section:

      fill h i = "^p(" ++ show i ++ ")^ca(1,wss)" ++ h ++ "^p(" ++ show i ++ ")^ca()"

And create wss script containing:

xdotool key <prefmodkey>+space

Does anyone know if there are ways to send commands to XMonad without xdotool?

Thanks gotmor for providing these new features.

Can we see your whole xmonad and dzen configs as well?  I remember seeing the shots you posted in the monthly threads.

Offline

#178 2009-02-14 19:19:14

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

Re: dzen & xmobar Hacking Thread

Sure here you go:

http://confiles.com/download.php/1201/xmonad.hs

http://confiles.com/download.php/1202/.xdzenconky

Using symbols found on AUR atm. Can't remember their name, but they are Japanese - I think.

Edit: At the moment the implementation of the ^ca() is really dirty and it does not work with doF (Shift.w ""). I'm trying to find a better solution and I guess I will eventually find one.

Edit2: To get doF (W.shift "") to work write the dzen escape sequences as well. I.e. (W.shift "^ca(1,ws1)web^ca()").

Last edited by Ashren (2009-02-14 21:54:23)

Offline

#179 2009-03-17 12:38:37

McManiaC
Member
Registered: 2009-03-06
Posts: 15

Re: dzen & xmobar Hacking Thread

Nice stuff, Ashren. I modified it a bit:

My xmonad.hs:

myWorkspaces            :: [String]
myWorkspaces            = clickable . (map dzenEscape) $ nWorkspaces 9 ["web", "irc", "com"]

  where nWorkspaces n []= map show [1 .. n]
        nWorkspaces n l = init l ++ map show [length l .. n] ++ [last l]
        clickable l     = [ "^ca(1,superkey " ++ show (n) ++ ")" ++ ws ++ "^ca()" |
                            (i,ws) <- zip [1..] l,
                            let n = if i == 10 then 0 else i ] -- needed for 10 workspaces

"superkey" in /usr/sbin:

#!/bin/sh
xdotool key super+$1

Works perfect. smile

And thats what it looks like:

http://www.n-sch.de/clickable.png


Oh, and if youre interested in my conkybar (using offlineimap + mutt for my mailboxes):

background no
out_to_console yes
update_interval 1.0
total_run_times 0
use_spacer no
mail_spool /home/nils/.mail/nsch/INBOX/
mail_spool /home/nils/.mail/uni/INBOX/

# Clean Layout:
#
#
# ^fg(#991133)^ca(1,urxvt -name ncmpcpp -e ncmpcpp)^i(.dzen/mpd.xbm) ${mpd_smart}^ca() 
# 
#     ^ca(1,mpc prev)^i(.dzen/prev.xbm)^ca()
#     ^ca(1,mpc toggle)^i(.dzen/pause.xbm)^ca()
#     ^ca(1,mpc next)^i(.dzen/next.xbm)^ca()
# 
# ^fg()|^fg(#74c44f)
#     ^ca(1,urxvt -name mutt -e mutt)^i(.dzen/mail.xbm) ${new_mails /home/nils/.mail/nsch/INBOX}/${new_mails /home/nils/.mail/uni/INBOX}^ca()
# 
# ${endif}${if_empty ${battery_time}}${else}^fg()|^fg(#3475aa)
#     ^i(.dzen/bat_full_01.xbm) ${battery BAT0} (${battery_time})
# 
# ${endif}^fg()|^fg(#92b19e)
#     ${time %a %Y.%m.%d} ^fg()|^fg(#ffffff) ${time %H:%M} 

TEXT
^fg(#991133)^ca(1,urxvt -name ncmpcpp -e ncmpcpp)^i(.dzen/mpd.xbm) ${mpd_smart}^ca() ^ca(1,mpc prev)^i(.dzen/prev.xbm)^ca() ^ca(1,mpc toggle)^i(.dzen/pause.xbm)^ca() ^ca(1,mpc next)^i(.dzen/next.xbm)^ca() ^fg()|^fg(#74c44f) ^ca(1,urxvt -name mutt -e mutt)^i(.dzen/mail.xbm) ${new_mails /home/nils/.mail/nsch/INBOX}/${new_mails /home/nils/.mail/uni/INBOX}^ca() ${endif}${if_empty ${battery_time}}${else}^fg()|^fg(#3475aa) ^i(.dzen/bat_full_01.xbm) ${battery BAT0} (${battery_time}) ${endif}^fg()|^fg(#92b19e) ${time %a %Y.%m.%d} ^fg()|^fg(#ffffff) ${time %H:%M}

(yes i do like the ^ca a lot wink )

Last edited by McManiaC (2009-03-17 15:25:18)

Offline

#180 2009-03-17 14:16:14

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

Re: dzen & xmobar Hacking Thread

Great McManiac, been struggling a bit to implement this properly. BTW you do not need a separate script for your xdotool command anymore as the newest dzen svn revision can handle whitespaces. In effect you can create a variable in xmonad.hs to handle this now i.e.: superKey = "xdotool key super+". Will try your suggestion this evening.

big_smile

Last edited by Ashren (2009-03-17 14:16:51)

Offline

#181 2009-03-17 14:28:17

McManiaC
Member
Registered: 2009-03-06
Posts: 15

Re: dzen & xmobar Hacking Thread

Indeed, you can just use

        clickable l     = [ "^ca(1,xdotool key super+" ++ show (n) ++ ")" ++ ws ++ "^ca()" |
                            (i,ws) <- zip [1..] l,
                            let n = if i == 10 then 0 else i ] -- needed for 10 workspaces

/me goes to rm /usr/sbin/superkey cool

Last edited by McManiaC (2009-03-17 14:30:54)

Offline

#182 2009-03-17 21:26:29

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

Re: dzen & xmobar Hacking Thread

McManiac, I'm using your code now and it's working without a hitch - thanks. I have to find way to use this with LogHooks and pp instead, to avoid having to write the dzen escape sequences in the ManageHooks.

Last edited by Ashren (2009-03-17 21:26:54)

Offline

#183 2009-03-17 22:03:25

McManiaC
Member
Registered: 2009-03-06
Posts: 15

Re: dzen & xmobar Hacking Thread

Oooooh, I just understood what you were meaning since I never had that problem. wink

What I'm using is (remember: 0 is the first entry, 1 the second etc):

    , [ className =? "Firefox"          --> doF (W.shift (myWorkspaces !! 0))     ]

But you could use this, too:

import Data.List (isInfixOf)

myManageHook = composeAll . concat $

    -- Float apps
    [ [ className =? c                  --> doFloat | c <- myCFloats    ]
    , [ resource  =? r                  --> doFloat | r <- myRFloats    ]
    , [ title     =? t                  --> doFloat | t <- myTFloats    ]

    -- Workspaces
    , [ className =? "Firefox"            --> doF (W.shift ws) | ws <- myWorkspaces, "web" `isInfixOf` ws ]
    , [ more... ]
    ]

Maybe a mix of both might be best. smile I dont think it's possible to put the clickable-Function into the PP section since the PP takes the workspace list directly from the running "X environment" and you never know which workspace you're at...




Edit: Edit instead of reply.. neutral My previous post wasnt that important anyway.

Last edited by McManiaC (2009-03-17 23:00:45)

Offline

#184 2009-03-18 05:53:50

Paul-S
Member
From: Wales
Registered: 2008-02-04
Posts: 353

Re: dzen & xmobar Hacking Thread

McManiaC any chance of posting your full xmonad.hs and any scripts you use.

Cheers
Paul-S

Offline

#185 2009-03-18 08:14:04

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

Re: dzen & xmobar Hacking Thread

McManiaC your ManageHook solution i.e. (W.shift (myWorkspace !! 1)) works perfectly. Thank you for your contributions.

Offline

#186 2009-03-18 10:28:40

McManiaC
Member
Registered: 2009-03-06
Posts: 15

Re: dzen & xmobar Hacking Thread

Paul-S wrote:

McManiaC any chance of posting your full xmonad.hs and any scripts you use.

I will do, as soon as im "finished". smile At the moment I still have some issues like getting apps (ie mplayer, gpicview etc) into "real" fullscreen etc... So far I'm at 300+ lines. wink


Edit: See here: http://bbs.archlinux.org/viewtopic.php? … 00#p518000

Last edited by McManiaC (2009-03-18 14:33:02)

Offline

#187 2009-03-24 07:28:45

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

Re: dzen & xmobar Hacking Thread

Just a quick notice. The newest dzen2-svn revision (259) fixes the .pad issue with xft fonts. Thanks gotmor.

Offline

#188 2009-06-09 19:31:37

gladstone
Member
Registered: 2009-01-03
Posts: 74

Re: dzen & xmobar Hacking Thread

Here's a tasklist I've neatened up from linsovet.com:

#!/bin/sh
# Title:    dzen-tasklist.sh
# Author:   gladstone
# Version:  1.1.4 (2009-06-09)
# Source:   http://linsovet.com/content/xmonad-dzen-task-list-menu
# Depends:  dzen, wmctrl, gawk
#
# A dzen tasklist. Left-clicking on a menu item switches to the running
# apps workspace.
#   Add:
#        -fn $FONT
# if your dzen is compiled with XFT support.
#
# TODO:
# * Menu items display could be more pretty
# * Mousewheel to switch between items?
# * Once ran, how can new items be added to the list?

WHEREX="0"
WIDTH="500"
#FONT="-*-dejavu sans-medium-r-normal-*-9-*-*-*-*-*-*-*"
FG="#aaaaaa"
BG="#1a1a1a"

(echo "Task List"; wmctrl -l) | \
    dzen2 \
        -m -p -l 15 -x $WHEREX  -w $WIDTH -fg $FG -bg $BG -e \
'button1=menuprint;button3=exit;entertitle=uncollapse;leaveslave=collapse' | \
    awk '{system("wmctrl -s " $2)}'

Works well with an EWMH compatible xmonad.

Any suggestions regarding the thoughts in the "TODO" list?

Last edited by gladstone (2009-06-09 19:39:46)

Offline

#189 2009-06-10 12:18:41

unregistered
Member
Registered: 2008-04-09
Posts: 134

Re: dzen & xmobar Hacking Thread

ok so here's my xmobarrc config but when I start up the workspaces area which show the selected workspace [1], [2] ... etc shows up in yellow, how can I change it to green and make it display all workspaces even when I'm not using it?

Config { font = "-*-Fixed-Bold-R-Normal-*-13-*-*-*-*-*-*-*"
       , bgColor = "black"
       , fgColor = "green"
       , position = TopW L 90
       , lowerOnStart = True
       , commands = [ Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 10
                    , Run Memory ["-t","Mem: <usedratio>%"] 10
                    , Run Swap [] 10
                    , Run Network "wlan0" ["-L","0","-H","32","--normal","green","--high","red"] 10
                    , Run Network "ath0" ["-L","0","-H","32","--normal","green","--high","red"] 10
                    , Run Date "%a %b %_d %l:%M" "date" 10
                    , Run Battery [] 10
                    , Run StdinReader
                    ]
       , sepChar = "%"
       , alignSep = "}{"
       , template = "%StdinReader% }{ %cpu% | %memory%  %swap% | %wlan0%  %ath0% | %date% | %battery%"
       }

Last edited by unregistered (2009-06-11 10:22:29)

Offline

#190 2009-06-11 10:10:11

unregistered
Member
Registered: 2008-04-09
Posts: 134

Re: dzen & xmobar Hacking Thread

another thing would be why is it that although I'm using the network, the upload download speed stated in xmobar always remains at 0?

Offline

#191 2009-06-20 16:08:55

Allamgir
Member
Registered: 2009-06-11
Posts: 168

Re: dzen & xmobar Hacking Thread

I have xmobar set up right now, but I want to set all the text colors to match my gtk theme. The background is fine. I set the main foreground color to white, but there are some elements (such as the universal titlebar and the current workspace) that use different colors. I have not yet found a way to change these.

I want to make the titlebar this blue color: 6C9EAB or 108 158 171

And you know how the selected workspace has [] around it and is yellow? I want it to be this orange color: E04613 or 224 70 19

So far I've been tinkering with xmonad.hs and my xmobarrc files, but I haven't been able to find ways to change these colors. How can it be done? I don't want to switch to dzen that much because these colors are all I really need to fix and dzen would require much more configuration (right?).


дɭɭɑӎɠїɾ

Offline

#192 2009-07-22 10:58:15

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: dzen & xmobar Hacking Thread

Is there a way to dynamically change the number of lines in the slave window? I'm trying to hack up a little mcabber notification thingy, and I'd like to display new messages in the slave window. Since I don't know beforehand how long these messages will be, I can't supply a definite number for -l.

I tried updating the variable I'm using for -l during runtime, but that didn't work:

!#/bin/bash
# Script is supposed to display the contents of two files;
# one with 5, the other with 10 lines. Each file is
# displayed for 1 second before the slave window gets
# cleared and the other file is displayed again.

LINES=2

while true; do
  echo "^tw() MULTILINES!"
  cat file-with-5-lines
  LINES=$(cat file-with-5-lines | wc -l)
  sleep 1
  echo "^cs()"
  cat file-with-10-lines
  LINES=$(cat file-with-10-lines | wc -l)
  sleep 1
  echo "^cs()"
done | dzen2 -p -l ${LINES}

Dzen only takes the initial value of LINES=2. If I don't supply the initial value, dzen doesn't start at all (which makes sense). Killing the old instance of dzen and launching a new one is the only way around this I can think of ATM.

So, is this a problem with dzen, or is it just me and my lacking scripting capabilties? If it really is with dzen, I'm gonna file a feature request. smile

Offline

#193 2009-07-22 13:41:09

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: dzen & xmobar Hacking Thread

@ unregistered and Allamgir

the formatting of that xmonad info (workspace, layout, title) is defined entirely by xmonad.hs;  xmobar simply reads %StdinReader%.

do some research on your logHook.  here's mine for reference:

myLogHook h = dynamicLogWithPP $ defaultPP
  { ppCurrent         = dzenColor "#303030" "#909090" . pad
  , ppHidden          = dzenColor "#909090" "" . pad
  , ppHiddenNoWindows = dzenColor "#606060" "" . pad
  , ppLayout          = dzenColor "#909090" "" . pad
  , ppUrgent          = wrap (dzenColor "#ff0000" "" "{") (dzenColor "#ff0000" "" "}") . pad
  , ppTitle           = wrap "^fg(#909090)[ " " ]^fg()" . shorten 40
  , ppWsSep           = ""
  , ppSep             = "  "
  , ppOutput          = hPutStrLn h
  }

this defines color formatting for dzen, but one can simply s/dzenColor/xmobarColor (in all but ppTitle).  alot of info available on xmonad.org.  good luck!

Last edited by brisbin33 (2009-07-22 13:42:09)

Offline

#194 2009-07-22 18:27:57

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: dzen & xmobar Hacking Thread

Got the first part down: Mcabber notifications using inotifywait. The number of new messages is displayed in a dzen instance, number's color changes to red if there are more than zero new messages. Inotail doesn't work with FIFOs on my machine, and it has other problems (it only looks for entire new lines and doesn't care if a line has changed although the line number is still the same), and I couldn't append anything to its output (like formatting information for dzen), so I chose a different approach using inotifywait.

NUMBER_UNREADFILE is the name of the file where mcabber stores the number of unread messages.

#!/bin/bash

FN="-*-terminus-*-*-*-*-12-*-*-*-*-*-iso10646-*"
NUMBER_UNREADFILE="/home/patrice/.mcabber/number_unread"

# Output to dzen:
im-notification-output() {
  if [[ $(cat $NUMBER_UNREADFILE) -eq 0 ]]; then
    echo "^tw()$(cat $NUMBER_UNREADFILE)^fg()"
  else
    echo "^tw()^fg(red)$(cat $NUMBER_UNREADFILE)^fg()"
  fi
}

# The actual loop:
im-notification() {
im-notification-output
while true; do
  inotifywait "$NUMBER_UNREADFILE" > /dev/null 2>&1
  im-notification-output
done
}

im-notification | dzen2 -p -fn $FN

I'm very open to code corrections since this is, like, my first bash script that is actually useful. I tried shoving $(cat $NUMBER_UNREADFILE) into a variable as well, but the script insisted on returning the initial value instead of the updated one. Is there any way around this?
Also, on a sidenote, I tried making the number flash (appear/disappear every other second), which is kinda difficult using this approach. Does anyone have an idea on how this might be done?

Offline

#195 2009-07-27 19:40:28

Allamgir
Member
Registered: 2009-06-11
Posts: 168

Re: dzen & xmobar Hacking Thread

I'm having some trouble creating a script for dzen to read from. I have all the information ready in bash script form, and it creates a line that displays all of it. I am just struggling to get xbm icons to display in place of text labels. Here is the script below. It doesn't work because the "print" command at the bottom is not recognized, but it has enough so that you guys and girls might understand what I'm trying to get. I have two dzens set up to look like a single bar, and I wanted to pipe this information to the second dzen2.

#!/bin/bash
network(){
iwconfig wlan0 2>&1 | grep -q no\ wireless\ extensions\. && {
  echo wired
  exit 0
}

essid=`iwconfig wlan0 | awk -F '"' '/ESSID/ {print $2}'`
stngth=`iwconfig wlan0 | awk -F '=' '/Quality/ {print $2}' | cut -d '/' -f 1`
bars=`expr $stngth / 10`

case $bars in
  0)  bar='[-------]' ;;
  1)  bar='[#------]' ;;
  2)  bar='[##-----]' ;;
  3)  bar='[###----]' ;;
  4)  bar='[####---]' ;;
  5)  bar='[#####--]' ;;
  6)  bar='[######-]' ;;
  7)  bar='[#######]' ;;
  *)  bar='[--!!!--]' ;;
esac

echo $essid$bar

exit 0
}

volume(){
vol=$(amixer get Master | awk -F'[]%[]' '/%/ {if ($7 == "off") { print "MM" } else { print $2 }}' | head -n 1)

echo Vol: $vol%

exit 0
}

battery(){

echo "acpi | awk '{ print $3 $4, $5 }' | sed 's/\,//g;s/Full/\[F\]/g;s/Charging/\[C\]/g;s/Discharging/\[D\]/g"

exit 0
}

load(){

echo "cat /proc/loadavg | cut -c 1-14"

exit 0
}

while true; do
    print "^i(/home/agi/.dzen_bitmaps/battery.xbm)`battery` Load: `load` ^i(/home/agi/.dzen_bitmaps/volume.xbm)`volume` `network` `date '+%I:%M%p %a %m-%d-%Y'`"
    sleep 1
done

Can anyone help? Btw, it's a .sh script. Let me know if that's causing any problems.

If there's a better way to do this (that still uses very little resources) and perhaps updates even more often than every second, please let me know.

Last edited by Allamgir (2009-07-27 19:41:06)


дɭɭɑӎɠїɾ

Offline

#196 2009-07-27 20:10:17

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: dzen & xmobar Hacking Thread

print's not a bash command, use echo.

while true; do
  echo "whatever you want"
  sleep 1
done | dzen2 --options

and take the [exit 0]'s out of those functions, else your script will exit the first time any one of them is run.

/edit: that script is more doomed for failure than i thought big_smile.  take the exit 0's out like i said and rewrite that network function like this:

network() {
  if iwconfig wlan0 2>&1 | grep -q no\ wireless\ extensions\. ; then
    echo wired
  else
    essid=`iwconfig wlan0 | awk -F '"' '/ESSID/ {print $2}'`
    stngth=`iwconfig wlan0 | awk -F '=' '/Quality/ {print $2}' | cut -d '/' -f 1`
    bars=`expr $stngth / 10`

    case $bars in
      0)  bar='[-------]' ;;
      1)  bar='[#------]' ;;
      2)  bar='[##-----]' ;;
      3)  bar='[###----]' ;;
      4)  bar='[####---]' ;;
      5)  bar='[#####--]' ;;
      6)  bar='[######-]' ;;
      7)  bar='[#######]' ;;
      *)  bar='[--!!!--]' ;;
    esac

    echo $essid$bar
  fi
}

/edit2: load() should also be

echo "$(cat /proc/loadavg | cut -c 1-14)"

or more simply, just

cat /proc/loadavg | cut -c 1-14

the same change is needed with battery()

ok... i'm done for now.

Last edited by brisbin33 (2009-07-27 20:33:18)

Offline

#197 2009-07-27 20:17:29

McManiaC
Member
Registered: 2009-03-06
Posts: 15

Re: dzen & xmobar Hacking Thread

Or just use conky. cool

Last edited by McManiaC (2009-07-27 20:17:42)

Offline

#198 2009-07-27 20:28:43

Allamgir
Member
Registered: 2009-06-11
Posts: 168

Re: dzen & xmobar Hacking Thread

Yes! Thank you! I fixed up that failure of a script and finally got something I like smile

McManiaC, how is conky with resource usage? I tried it a while ago and it ate up resources like nobody's business compared to using shell scripts.


Also, what about gdbar scripts? Do I just put those together in a similar fashion, then use echo to line up the outputs and pipe it to dzen? Is there something else I'm missing? I'm talking about the ones found here.

Last edited by Allamgir (2009-07-27 20:32:30)


дɭɭɑӎɠїɾ

Offline

#199 2009-09-10 23:09:54

YamiFrankc
Member
From: Mexico
Registered: 2009-06-19
Posts: 177
Website

Re: dzen & xmobar Hacking Thread

Hi Guys.
I have some questions,has im very noob in scripts and other things.

I have been messing around with dzen,an understood somethins of it.
But,i have like 10 instances running at the same time,and in diferent places of the screen. How Can i make a single instance with all i want?
Also,to make dzen's window to act like a panel(in the way of be like a 'limit' between screen border and windows and dont let them go more that way),and to only be overlapped by full screen windows?

Also,some problems or suggestions with the wiki scripts tongue

Im using the mpd widget script.How can i make to it show the song time(3:55/4:00) instead of a bar?
The battery one is not working. It stays red always.
The wireless one dont work neither. It only shows my IP and router's one too. Mi interface is wlan1
How can i make the volume-meter work with oss?

Sorry for all the questions...
Do you know good books to start my life as a bash/zsh scripter?

A lot of thanks

Last edited by YamiFrankc (2009-09-10 23:11:36)


Thanks and greetings.

Offline

#200 2009-09-14 14:43:39

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: dzen & xmobar Hacking Thread

YamiFrankc wrote:

Hi Guys.
I have some questions,has im very noob in scripts and other things.

I have been messing around with dzen,an understood somethins of it.
But,i have like 10 instances running at the same time,and in diferent places of the screen. How Can i make a single instance with all i want?

There's dmplex.

YamiFrankc wrote:

Do you know good books to start my life as a bash/zsh scripter?

The Advanced Bash Scripting Guide. Don't worry, it's not as advanced as it sounds, and has a fairly gentle learning curve.

Last edited by Runiq (2009-09-14 14:51:06)

Offline

Board footer

Powered by FluxBB