You are not logged in.
Well, you just need to paste this somewhere near the top of your wmiirc...
#A more complicated set of statusbar functions
#As of now, use dzen for your OSD needs.
#Maybe switch to libnotify if I can get it to work adequately
#TODO: Nice, fancy string array to keep track of (and easily change) bar names/content... Sorta like the daemons list or whatever
#Urgent bar info will be garishly-colored and flash.
BARCOLORS_URGENT='#ff4747 #e8ae5b #ff4747'
BARCOLORS_URGENT1='#ff4747 #e8ae5b #ff4747'
BARCOLORS_URGENT2='#e8ae5b #ff4747 #e8ae5b'
BARCOLORS_NORMAL='#0480bd #111111 #111111'
BARCOLORS_GREEN='#afc81c #111111 #111111'
BARCOLORS_AMBER='#E8AE5B #111111 #111111'
BARCOLORS_RED='#ff4747 #111111 #111111'
BARCOLORS_GRAY='#555555 #111111 #111111'
#State of animation for the blinking bars
BLINK_STATE=0
#Current IPv4 Address of the primary nic.
#Needed by statusbar function and OSD Function, so global it is
IP4=""
MPDADDR="localhost:6600"
createStatusBars()
{
#wmii displays bars in alphabetical order, changing the numbers in front
#of the names will reorder the bars.
#Just remember to change them in the update and remove functions also.
echo -n $BARCOLORS_NORMAL | wmiir create /lbar/00time
echo -n $BARCOLORS_NORMAL | wmiir create /lbar/01net
echo -n $BARCOLORS_NORMAL | wmiir create /lbar/02load
echo -n $BARCOLORS_NORMAL | wmiir create /lbar/03mem
echo -n $BARCOLORS_NORMAL | wmiir create /lbar/06vol
echo -n $BARCOLORS_NORMAL | wmiir create /lbar/04fs1
echo -n $BARCOLORS_NORMAL | wmiir create /lbar/05bat
echo -n $BARCOLORS_NORMAL | wmiir create /lbar/07mpd
}
updateStatusBars()
{
#Update Blink State
if [ $BLINK_STATE -eq 0 ]
then
BLINK_STATE=1
BARCOLORS_URGENT=${BARCOLORS_URGENT1}
else
if [ $BLINK_STATE -eq 1 ]
then
BLINK_STATE=0
BARCOLORS_URGENT=${BARCOLORS_URGENT2}
fi
fi
echo -n $(date +'%a %b %d %Y %H:%M') ' ' | wmiir write /lbar/00time
netStatus 'wlan0' | wmiir write /lbar/01net
batteryUse 'BAT0' | wmiir write /lbar/05bat
fsStatus '/' | wmiir write /lbar/04fs1
memStatus | wmiir write /lbar/03mem
echo -n 'LD:'$(uptime | sed 's/.*://; s/,//g') ' ' | wmiir write /lbar/02load
mpdStatus | wmiir write /lbar/07mpd
volLvl Master | wmiir write /lbar/06vol
#Add a spacer to the "end" of the bar... Actually the beginning of rbar.
#Without this, the first tag on rbar will stretch across the space in the middle.
wmiir create /rbar/...spacer
}
removeStatusBars()
{
wmiir remove /lbar/00time
wmiir remove /lbar/01net
wmiir remove /lbar/02load
wmiir remove /lbar/03mem
wmiir remove /lbar/04fs1
wmiir remove /lbar/06vol
wmiir remove /lbar/05bat
wmiir remove /lbar/07mpd
}
#Display Battery Information
batteryUse()
{
CURRENT=$(cat /sys/class/power_supply/$1/charge_now)
FULL=$(cat /sys/class/power_supply/$1/charge_full_design)
PERCENT=$(echo 'scale=2; ('${CURRENT}'/'${FULL}') * 100' |
bc | sed -e 's/\([0-9]*\)\.[0-9]*/\1/')
STATUS=$(cat /sys/class/power_supply/$1/status)
#Simple awk program just divides up the remaining capcity (in mA-Hours)
#by the current charge/discgarge rate (in mA) and then divides the result
#up into hours an minutes.
TIME=$(cat /proc/acpi/battery/BAT0/state | awk '/rate/ {rate=$3}\
/capacity/ {cap=$3}\
END {time=cap/rate;\
hours = int(time);\
minutes = int((time - hours) * 60);\
printf("%.02d:%.02d\n", hours,minutes)}')
if [ $STATUS = "Discharging" ]
then
if [ $PERCENT -lt 3 ]
then
echo -n $BARCOLORS_URGENT $1': LOW -' $PERCENT'%' '-' $TIME ' '
else
if [ $PERCENT -lt 11 ]
then
echo -n $BARCOLORS_RED $1': Dis -' $PERCENT'%' '-' $TIME ' '
else
if [ $PERCENT -lt 26 ]
then
echo -n $BARCOLORS_AMBER $1': Dis -' $PERCENT'%' '-' $TIME ' '
else
echo -n $BARCOLORS_GREEN $1': Dis -' $PERCENT'%' '-' $TIME ' '
fi
fi
fi
else
echo -n $BARCOLORS_NORMAL $1':' $(echo $STATUS |
sed -ne 's/\(...\).*/\1/p') - $PERCENT'%' '-' $TIME ' '
fi
}
#Display Volume Information
volLvl()
{
OUT=$(amixer get $1)
VOLUME=$( echo -n $OUT |
sed -ne 's/[^\[]*\([\[[0-9]*%\]\).*/\1/p')
STATE=$( echo -n $OUT |
sed -ne 's/off/s/p')
if [ -e $STATE ]
then
echo -n $BARCOLORS_NORMAL 'VOL: '$1':' $VOLUME ' '
else
echo -n $BARCOLORS_GRAY 'VOL: '$1':' $VOLUME ' '
fi
}
#Display FS Usage
fsStatus()
{
MEM=$(df -m | grep $1);
TOTAL=$(echo $MEM | awk 'END{print $2 }')
USED=$(echo $MEM | awk 'END{print $3}')
FREE=$(echo $MEM | awk 'END{print $4}')
PERCENT=$(echo 'scale=2; ('${USED}'/'${TOTAL}') * 100' |
bc| sed -e 's/\([0-9]*\)\.[0-9]*/\1/')
USED=$(echo 'scale=2; base='$USED';\
if( base >= 1000000){\
base = base/1000000;\
print base; "TiB"}\
else {print base/1000; "GiB"}' | bc |
sed -e 's/\([0-9]*\)\.[0-9]*/\1/')
TOTAL=$(echo 'scale=2;base='$TOTAL';\
if( base >= 1000000){\
base = base/1000000;\
print base/1000; "TiB"}\
else {print base/1000; "GiB"}' | bc |
sed -e 's/\([0-9]*\)\.[0-9]*/\1/')
if [ $PERCENT -lt 50 ]
then
echo -n $BARCOLORS_GREEN $1':' $USED' /' $TOTAL ' '
else
if [ $PERCENT -lt 90 ]
then
echo -n $BARCOLORS_AMiBER $1':' $USED'/' $TOTAL ' '
else
echo -n $BARCOLORS_RED $1':' $USED'/' $TOTAL ' '
fi
fi
}
#Display Memory Usage
memStatus()
{
MEM=$(free -m | grep -e 'buffers\/cache');
USED=$(echo $MEM | sed -ne 's/[^0-9]*\([0-9]*\).*/\1/p')
FREE=$(echo $MEM | sed -ne 's/[^0-9]*\ *[0-9]*\ *\([0-9]*\).*/\1/p')
TOTAL=$(echo 'scale=2; per=('${USED}'+'${FREE}'); print per' |
bc| sed -e 's/\([0-9]*\)\.[0-9]*/\1/')
PERCENT=$(echo 'scale=2; ('${USED}'/'${TOTAL}') * 100' |
bc| sed -e 's/\([0-9]*\)\.[0-9]*/\1/')
USED=$(echo 'scale=2; base='$USED';\
if( base >= 1000){\
base = base/1000;\
print base; "GiB"}\
else {print base; "MiB"}' | bc )
TOTAL=$(echo 'scale=2;base='$TOTAL';\
if( base >= 1000){\
base = base/1000;\
print base; "GiB"}\
else {print base; "MiB"}' | bc )
if [ $PERCENT -lt 50 ]
then
echo -n $BARCOLORS_GREEN ' Mem:' $USED' /' $TOTAL ' '
else
if [ $PERCENT -lt 90 ]
then
echo -n $BARCOLORS_AMiBER ' Mem:' $USED'/' $TOTAL ' '
else
echo -n $BARCOLORS_RED 'Mem' $USED'/' $TOTAL ' '
fi
fi
}
#Display MPD Information
mpdStatus()
{
#Default Address
if [ -z "$1" ]
then
ADDR="localhost:6600"
else
ADDR=$1
fi
#Status
STATUS=`echo status | socat - TCP4:localhost:6600 | grep state | sed -e 's/.*: //'`
case $STATUS in
stop)
echo -n $BARCOLORS_RED 'MPD: Stopped'
;;
play | pause)
TITLE=`echo currentsong | socat - TCP4:localhost:6600 | grep Title | sed -e 's/.*: //'`
ARTIST=`echo currentsong | socat - TCP4:localhost:6600 | grep AlbumArtist | sed -e 's/.*: //'`
if [ -z $ARTIST ]
then
ARTIST=`echo currentsong | socat - TCP4:localhost:6600 | grep Artist | sed -e 's/.*: //'`
fi
if [ "$STATUS" = "play" ]
then
echo -n $BARCOLORS_NORMAL 'MPD:' $TITLE '-' $ARTIST
else
echo -n $BARCOLORS_AMBER 'MPD:' $TITLE '-' $ARTIST
fi
;;
*)
echo -n 'Something bad happened with MPD'
;;
esac
}
#Display Network Information
netStatus()
{
CONFDATA=$(iwconfig $1)
#As of now, the only requirement for connection is that we have an IP Address
IP4=$(ifconfig wlan0 | sed -ne 's/\ *inet addr:\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/p')
if [ -e $IP4 ]
then
echo -n $BARCOLORS_RED $1: ' DOWN! ' ' '
else
QUALITY=$(echo ${CONFDATA} | sed -e 's/.*Link Quality=\([0-9]*\).*/\1/')
if [ $QUALITY -lt 50 ]
then
echo -n $BARCOLORS_AMBER $1: "UP" : ${QUALITY} ' '
else
echo -n $BARCOLORS_GREEN $1: "UP" : ${QUALITY} ' '
fi
fi
}
#TODO: Replace specific device names with more flexible solution
#Propsed: Rename bars after relevant device. Case statements like *wlan0 or something likethat
popupOSD()
{
#Remove Other Instances of dzen2
killall -s SIGKILL dzen2
case $1 in
00time)
cal | dzen2 -bg '#111111' -fn drift -x 0 -y 742 -w 140 -l 6 -p 4
;;
01net)
CONFDATA=$(iwconfig wlan0)
ESSID=$(echo ${CONFDATA} | sed -ne 's/.*ESSID:"\([^"]*\)".*/\1/p')
GATEWAY=$(route | grep wlan0 | awk '/default/{print $2}')
IP4=$(ifconfig wlan0 | sed -ne 's/\ *inet addr:\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\).*/\1/p')
AP=$(echo ${CONFDATA} | sed -ne 's/.*Access Point:\ *\(..:..:..:..:..:..\).*/\1/p')
echo "ESSID: $ESSID\nGatewy$GATEWAY\nOwnIP:$IP4\nAP: $AP" |
dzen2 -bg '#111111' -fn drift -x 141 -y 742 -w 130 -l 3 -p 4 -ta left
;;
02load)
sensors | sed -ne 's/Core \([0-3]:\)\ *.\([0-9]*\.[0-9]*\).*/Core \1 \2C/p' |
dzen2 -bg '#111111' -fn drift -x 240 -y 742 -w 123 -l 3 -p 4 -ta left
;;
03mem)
free -m | awk '/Mem/{printf("Mem: %sMiB / %sMiB\nBuffers: %sMiB\nCached: %sMiB\n", $3,$2,$6,$7 )}\
/Swap/{printf("Swap: %sMiB / %sMiB\n", $3, $2)}' |
dzen2 -bg '#111111' -fn drift -x 368 -y 742 -w 150 -l 3 -p 4 -ta left
;;
04fs1)
cat /etc/mtab | grep -e ' / ' | awk 'END{printf ("%s\n%s\n%s\n%s\n", $1, $2, $3, $4)}' |
dzen2 -bg '#111111' -fn drift -x 509 -y 742 -w 150 -l 3 -p 4 -ta left
;;
05fs2)
cat /etc/mtab | grep -e 'winDrive' | awk 'END{printf ("%s\n%s\n%s\n%s\n", $1, $2, $3, $4)}' |
dzen2 -bg '#111111' -fn drift -x 625 -y 742 -w 150 -l 3 -p 4 -ta left
;;
05bat)
;;
07mpd)
;;
esac
}
And make your "status" action look like this:
Action status
set +xv
if removeStatusBars 2>/dev/null; then
sleep 2
fi
createStatusBars
while true; do
updateStatusBars
sleep 0.5
done
For the OSDs (requires dzen) you need to add this Event:
Event RightBarClick
shift
wmiir xwrite /ctl view "$@"
For best results, I would put the tags on the right side instead of the left. This should keep them from getting mixed in with the status stuff. With wmii-hg, I think you just need to change the following:
Replace the Right Bar Click Event with this:
Event RightBarClick
shift
wmiir xwrite /ctl view "$@"
And Replace the Tag Bar Setup stuff at the bottom with this:
# Setup Tag Bar
IFS="$wi_newline"
wmiir rm $(wmiir ls /rbar | sed 's,^,/rbar/,') >/dev/null
seltag=$(wmiir read /tag/sel/ctl | sed 1q)
unset IFS
wi_tags | while read tag
do
if [ "$tag" = "$seltag" ]; then
echo "$WMII_FOCUSCOLORS" "$tag"
else
echo "$WMII_NORMCOLORS" "$tag"
fi | wmiir create "/rbar/$tag"
done
And change the tag events...
Event CreateTag
echo "$WMII_NORMCOLORS" "$@" | wmiir create "/rbar/$@"
Event DestroyTag
wmiir remove "/rbar/$@"
Event FocusTag
wmiir xwrite "/rbar/$@" "$WMII_FOCUSCOLORS" "$@"
Event UnfocusTag
wmiir xwrite "/rbar/$@" "$WMII_NORMCOLORS" "$@"
Event UrgentTag
shift
wmiir xwrite "/rbar/$@" "*$@"
Event NotUrgentTag
shift
wmiir xwrite "/rbar/$@" "$@"
End result should look like this (although I'm not using the disk space monitor)
If you have any trouble, just complain, and I'll try to help out xD
Last edited by alexandrite (2010-04-12 21:59:36)
Offline
Thanks @alexandrite.
One clarification and one doubt:
Clarification
The configuration requires the following two packages:
$ sudo pacman -S bc
$ sudo pacman -S socat
Doubt
It is mandatory to have wmii-hg to get the 'workspaces' in the right position?
Offline
Yeah, I guess I kinda forgot about those dependencies.
Also, I forgot that moving the tagbar also requires replacing a few more actions:
Event CreateTag
echo "$WMII_NORMCOLORS" "$@" | wmiir create "/rbar/$@"
Event DestroyTag
wmiir remove "/rbar/$@"
Event FocusTag
wmiir xwrite "/rbar/$@" "$WMII_FOCUSCOLORS" "$@"
Event UnfocusTag
wmiir xwrite "/rbar/$@" "$WMII_NORMCOLORS" "$@"
Event UrgentTag
shift
wmiir xwrite "/rbar/$@" "*$@"
Event NotUrgentTag
shift
wmiir xwrite "/rbar/$@" "$@"
After changing these, everything should work on wmii-hg.
For wmii-3.5, you'll wanna replace the above, AND your tagbar setup (like 5 sections from the bottom) with this:
#Setup Tag Bar
seltag="$(wmiir read /tag/sel/ctl 2>/dev/null)"
wmiir ls /rbar |
while read bar; do
wmiir remove "/rbar/$bar"
done
wmiir ls /tag | sed -e 's|/||; /^sel$/d' |
while read tag; do
if [ "X$tag" = "X$seltag" ]; then
echo "$WMII_FOCUSCOLORS" "$tag" | wmiir create "/rbar/$tag"
else
echo "$WMII_NORMCOLORS" "$tag" | wmiir create "/rbar/$tag"
fi
done
I have a complete wmiirc for both versions if there's still trouble.
Last edited by alexandrite (2010-04-12 22:18:39)
Offline
Two things:
1. I get on the right position of MPD a nil windows
2. The Memory doesn't show like yours .
Here's a image.
Btw, thanks for the help.
Offline
Hm... The "nil" was just supposed to be a blank space between the bars. Without it, the leftmost tag button would expand to fill any space between them. On hg it's blank, but I guess it says "nil" because there is no text contained in it...
Maybe try adding this to the end of updateStatusBars()
wmiir xwrite /rbar/...spacer " "
If that doesn't work, then deleting the last line of updateStatusBars() should just get rid of it entirely.
As for the memory, the stuff on the right side of it is actually a separate bar to monitor disk space. I don't use it on my system, but I put it back in in case someone wanted it. You can change what disk it monitors by changing the '/' in:
fsStatus '/' | wmiir write /lbar/04fs1
to whatever mount point you want to monitor. If you want to remove it entirely, just delete the lines pertaining to it in the update, remove, and create functions. Should be one line each.
Thanks for the testing by the way
Offline
Ok. I solved the memory display. But the problem with the nil windows persist
Offline
Hm... Care to post the output of these?
wmiir ls /lbar
and
wmiir ls /rbar
Offline
Hm... Care to post the output of these?
wmiir ls /lbar
> wmiir ls /lbar
00time
01net
02load
03mem
04fs1
05bat
06vol
07mpd
nil
and
wmiir ls /rbar
> wmiir ls /rbar
...spacer
dev1
music
www
Offline
I think that has to do with the way you set up your named tags. The default should remove the initial "nil" you have in the tagbar before you open a window.
Actually, since you have those named tag things, you might try removing the Tagbar setup stuff that I suggested... That code would just be for the standard numbered tags anyway.
Last edited by alexandrite (2010-04-17 20:55:18)
Offline
Thanks for answer.
The default should remove the initial "nil" you have in the tagbar before you open a window.
hmm, i don't know how to that. I try to find something similar but with no luck.
Actually, since you have those named tag things, you might try removing the Tagbar setup stuff that I suggested... That code would just be for the standard numbered tags anyway.
indeed, i don't use that setup.
TIA.
Offline
I guess try removing this:
#Setup Tag Bar
seltag="$(wmiir read /tag/sel/ctl 2>/dev/null)"
wmiir ls /rbar |
while read bar; do
wmiir remove "/rbar/$bar"
done
wmiir ls /tag | sed -e 's|/||; /^sel$/d' |
while read tag; do
if [ "X$tag" = "X$seltag" ]; then
echo "$WMII_FOCUSCOLORS" "$tag" | wmiir create "/rbar/$tag"
else
echo "$WMII_NORMCOLORS" "$tag" | wmiir create "/rbar/$tag"
fi
done
That's only for the numbered tag setup.
If that doesn't work, then paste your wmiirc and I'll see about fixing it myself xD
Offline
Dude i solved the problem adding the lines of your last post. By an unknown reason i don't have it.
Thanks so much alexandrite!!! All is done.
Offline
Hah! I guess all's well that ends well. Glad to be of help. Enjoy your shiny (somewhat frustrating) statusbar.
Offline
Why is the version in extra not wmii 3.9, which is the recomended version, instead of 3.6, which is marked as "historical"?
I may have missed something important.
Last edited by fifafrazer (2010-06-04 16:35:55)
Offline
Why is the version in extra not wmii 3.9, which is the recomended version, instead of 3.6, which is marked as "historical"?
I may have missed something important.
3.9 was just tagged recently (May 21, to be exact).
Since there's no maintainer, I'd guess there just hasn't been a dev with the chance and willingness to update it yet. It has already been flagged out-of-date.
(If you're anxious to use newer code, there's always wmii-hg from the AUR.)
Offline
Is it possible to use a different color for the bar of floating windows?
I want to make them stand out from the rest. The small border lines that tells you what mode the window is in can easily be overlooked.
Offline
How are you debugging your scripts? Is there some kind of wmii log file? I use an almost vanilla wmiirc, but MOD-SHIFT-2 doesn't work. It should retag the selected window to 2, but it doesnt. The nine other numbers are working, and I can tag the window to 2 with "mod-shift-t 2 enter".
Offline
There is no wmii log file as far as I know but if you have a login manager like slim you could try checking its login file and that of Xorg and dmesg for serious stuff. If MOD-SHIFT-2 is not working for you please paste your ~/.wmii-3.5/wmiirc file here so we can look at it.
Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.
Offline
I found out the MOD-SHIFT-2 thing was a hardware bug. It seems to be a dead key combination on my old Model M keyboard, where I have remapped caps lock to "Super" key.
It works on my other keyboard though.
Offline
Is it possible to use a different color for the bar of floating windows?
I want to make them stand out from the rest. The small border lines that tells you what mode the window is in can easily be overlooked.
AFAIK you cannot do that in a nice way. You can use the following hack though:
Event AreaFocus
if [ $1 = "~" ]; then
wmiir xwrite /ctl focuscolors $WMII_FOCUSCOLORS_FLOATING
else
wmiir xwrite /ctl focuscolors $WMII_FOCUSCOLORS
fi
Put this somewhere in the events() function next to the other Events and set WMII_FOCUSCOLORS_FLOATING at the beginning of your wmiirc to your liking. It's not nice and you'll notice some flickering, but it should work.
Offline
Anyone figured a way to restore/load sessions (i.e. groups of tags) including their clients and positions?
I've been using wmii with rumai (ruby library), and this is not built in, however the author reckons that should be possible, so i figured i'd ask here...
cheers
Offline
Hi folks,
I'm developing a game on a netbook. The netbook has a 1024x600 display and my game has a fixed res of 800x600. If, when I'm testing, I make the game window fullscreen it stretches the graphics, but if I leave it floating or stacked it squashes the window vertically as wmii wants to fit a titlebar in. Is it possible to configure wmii to run the game 800x600 in the middle of the screen? Either by not fitting fullscreen vertically or by running in floating mode without titlebar on that window?
Offline
Anyone figured a way to restore/load sessions (i.e. groups of tags) including their clients and positions?
I
Not sure if it is what you want, and perhaps you know already, but for a standard login session I just put the apps I want to run in my .xinitrc file and then I specify in my wmiirc tagging rules where to put that app, eg, for opera:
# Tagging Rules
wmiir write /tagrules <<!
/XMMS.*/ -> ~
/MPlayer.*/ -> ~
/tkremind.*/ -> ~3
/opera.*/ -> 2
/gimp.*/ -> 3
/vlc.*/ -> ~
HTH....
Philosophy is looking for a black cat in a dark room. Metaphysics is looking for a black cat in a dark room that isn't there. Religion is looking for a black cat in a dark room that isn't there and shouting "I found it!". Science is looking for a black cat in a dark room with a flashlight.
Offline
Hi, having a slight problem here. I want to use some bigger font, but witray stays the old height when I start X. Tried the default config already (only altered font size) but result remains the same.
When I restart wmii without killing X, the height fits.
My wmii starting section in xinitrc is just
exec wmii
Anybody has a clue?
Offline
I'm not sure if it's a proper solution, but moving the line with 'startup' in /etc/wmii-hg/wmiirc to the end of the file for example just after the 'xsetroot...' command fixes the problem. You are using the sh script, right?
This doesn't happen with the python wmiirc.
Offline