You are not logged in.
@andmars
Do you get the same syntax error when using "bash" instead of "sh". I know that most of the time they're the same thing (symlinked) but "sh" does not have to respect bashisms.
Thanks
Offline
@andmars
Do you get the same syntax error when using "bash" instead of "sh". I know that most of the time they're the same thing (symlinked) but "sh" does not have to respect bashisms.Thanks
you mean if I start with
#!/bin/sh
or
#!/bin/bash
Yes, I get the same syntax error.
Offline
hi,
you're getting that because you're using `sh` whereas the script in written in `bash`.
People get confused, but `sh` is _not_ `bash` and one should never assume it is.
so, POSIX `sh` doesn't know about `[[` or `=~` or the ERE after it, and so it fails.
try to use 'bash'. if bash fails then there might be something actually wrong.
edit: oh, I didn't see the answers.
The shebang ('#!/bin/..') is used only when you invoke the script directly
$ ./foo
calling an interpreter by hand will override it, so
$ sh foo
is using, 'sh', and
$ zsh foo
is using 'zsh'
no matter what the shebang says.
$ ./foo # so either try this
$ bash foo # or this
Last edited by c00kiemon5ter (2012-12-05 12:36:19)
.:[ git me! ] :.
Offline
Btw, in addition to cookies upsumming, then you stated that you sometimes use the code directly through .xinitrc, and sometimes through external script called from .xinitrc...
The file .xinitrc is always called by 'sh', no matter what the shebang is, so if you use the code from there, like I do, then make sure that sh is symlinked to bash, like the default arch install.
(.. Why the xorg devs(+ arch devs) decided to add a shebang to their default .xinitrc is really stupid imho, since it will never get interpreted as anything but a comment, and just adds confusion to users...)
Offline
Hello there!
I started using monsterwm a few days ago, however I immediately ran into problems, because of the (not really that common) keyboard layout that I use,
the (german) neo layout (www.neo-layout.org , german page), 'setxkbmap de neo' to activate.
My problem is: all hotkeys that I define which use a combination of MOD1/4 and regular keys, e.g. 'i' or 'r' or something, don't work.
However the keys are defined correcty, because when I switch back to a 'normal' qwertz layout, for example 'setxkbmap de', they work. Its only with a different layo
ut that they dont work.
Stuff that works includes: mod4 + number keys. mod1 + fn keys(but not mod4 + fn keys), mod1 + tab, and mod1/4 with mouse buttons also work.
Mod1 and Mod4 are set to defaults, alt and windows key.
I fear this is a more basic X11 bug or incompatibility, because xterm also doesn't work correctly with neo enabled,
while urxvt and all other applications I'm using(qtcreator, firefox, vim) detect all keys correctly.
Any ideas?
Cheers & Greetings,
Felix
Offline
Hi,
that's known and that's how it is at the moment
I do not know how keysyms can be transleted to keycodes in a consistent way across all locales.
what you can do is redifine keybinds for the other locale you use, ie
{ MOD1, XK_y, togglepanel, {NULL}}, /* usable with us layout */
{ MOD1, XK_z, togglepanel, {NULL}}, /* usable with de layout */
Last edited by c00kiemon5ter (2012-12-11 13:17:00)
.:[ git me! ] :.
Offline
mhh ok, but I could theoretically fix it for my locale?
So it works with my layout and not with other layouts anymore?
Since that sounds like it at most requires a lookup table from old keysyms -> new keysyms or sth. like that,
it doesn't sound like too much trouble to go through. Thats what I love about open-source software
Got any quick tips on that, like where I would get the new keysyms(or whatever) from,
and where I would need to change something in monsterwm?
Thanks
Offline
looking at the master branch
on config you define the keysyms on the keys[] array (line 57, the second column)
on monsterwm.c you have
1) on line 622 the grabkeys function
which registers the keys given on the keys[] array on config, to listen on.
2) on line 655 the keypress function
which is called when a registered keybind is triggered, and searches the appropriate action to do, from the keys[] array
this is where the changes would go probably.
what you'd need to do is find out how a press of 'y' on say 'us' layout
can be considered the same as the press of 'z' on a 'de' layout
Last edited by c00kiemon5ter (2012-12-12 11:53:35)
.:[ git me! ] :.
Offline
@cookie
I have these two lines as part of my .xinitrc:
urxvtd -q -f -o
urxvtc
In eg. dwm, then this isn't a problem, but for urxvtc to show up in monsterwm, I have to background urxvtc, even though it "backgrounds itself by default"(in contrary to urxvt).
I've even tried adding a 'sleep 5', between urxvtd and urxvtc just to test, even though it shouldn't be needed as I dont background urxvtd, and still no terminal shows up?
Also with monsterwm, and when having backgrounded urxvtc, then it still from time to time dosen't show up and I have to start it manually through my keybind.
Do you have any clue about why this is?
Offline
@c00kiemon5ter, thanks a lot for the monsterwm, it's great! The best wm whenever I was using, but I miss one thing - tray. It is posible to make a new branch or patch to support tray (stalonetray, trayer or something other)? Tray is useful for example in dropbox. Solution with xdotool and key bind does not satisfy me...
Offline
hey.. I've tried your wm.. It's great
Offline
Offline
I'm wondering why monsterwm handles loading/splash-screens the way it does?
Monsterwm doesn't handle window type hints.
I think I posted how to make it ignore splash screens and notifications way back, I'm not sure though.
Last edited by Cloudef (2012-12-29 09:44:19)
Offline
@hazeldf, hello and thanks
@mhertz
yep, monsterwm wants to be the first process inside X, so any other processes using X is known and can be handled by monsterwm.
if you use 'urxvtc; monsterwm;' then urxvtc starts before monsterwm, so monsterwm does not know about that window.
if you background urxvtc then monsterwm is most likely to be up first, as there is minimum setup.
that however leaves a small window for race conditions. the only way to I can think of to have apps start safely would be by
either polling until the monsterwm process is there, or wait until the monsterwm output fifo is there (assuming one uses that info for a panel or w/e ..)
that would can be done inside .xinitrc like:
while true
do
pgrep -x monsterwm || continue
# apps go here -- can optionally be backgrounded
urxvtc
foo_app
bar_app
firefox
# stop the loop
break
done &
start_monsterwm
one could also replace 'true' with a small sleep amount, like 'sleep .05'
this should be safe for anything you want to autostart
dwm does not need this as it picks up windows that were there before it was there,
this is why dwm can also "restart" itself keeping windows in place (not closing them)
andmars wrote:I'm wondering why monsterwm handles loading/splash-screens the way it does?
Monsterwm doesn't handle window type hints.
I think I posted how to make it ignore splash screens and notifications way back, I'm not sure though.
yep monsterwm ignores if the window is of type "splash screen" and just sets it to the appropriate size
I don't think you can work around that at its current state other than setting a rule to have the app spawn in floating mode
a solution would be to have monsterwm check the WM_NAME property along with the WM_CLASS and have a rule to set the window floating on a match.
this would work because splash screens do have a WM_NAME property set (while usually not a WM_CLASS)
and that property is different for the splash screen and the main window.
Ofcourse there is the other not-a-splash-screen-solution
just use 'lowriter --nologo' and you'll get only the main window
@c00kiemon5ter, thanks a lot for the monsterwm, it's great! The best wm whenever I was using, but I miss one thing - tray. It is posible to make a new branch or patch to support tray (stalonetray, trayer or something other)? Tray is useful for example in dropbox. Solution with xdotool and key bind does not satisfy me...
hi, you can do the following with stalonetray (I dont know about other tray docks),
what you want to do is make stalonetray work on its own, so in your .xinitrc make sure it starts before monsterwm is up
stalonetray &
sleep 1
start_monsterwm
1second between the call to the trayer and monsterwm should be more than enough.
this will make stalonetray appear on top left corner with 24px width and height (default and minimum stalonetray values)
so, in your monsterwm you want to set PANEL_HEIGHT to at least 24.
update config.h and .xinitrc, recompile and test it
everytime a new app appears/exits it will automatically grow/shrink itself
if you want to position it somewhere else you should play with the '--geometry' switch that stalonetray provides
and update .xinitrc with that switch and the appropriate value.
Last edited by c00kiemon5ter (2012-12-29 22:10:47)
.:[ git me! ] :.
Offline
my gimp hide the bar so I must manually move the gimp down to see the bar..
how can I set gimp position automatically?
Offline
@cookie
Thanks alot for the explenation and solution, mate!
I'm now using your example(with an added 'break' before 'done' ) and everything is perfect now!
Thanks again!
Offline
@c00kiemon5ter, thanks for the solution, I didn't know it was that easy.
Offline
I know that i asked before but i need someone to help me to use my script (plain version of my script) in monsterwm with some bar. What i need is to make the way it is coded in script but hardcoded version of it (in C) could do the trick as long as i can set time for refreshing stats. Atm i plan to update my script and use "sleep $timeout" so i can refresh all stats in desired period od time.
I know it is a lot to ask but can someone give me some hints about what to do, what bar is using the least resources, what is the best way to use it (bash script or hardcoded C) and how to achieve that? If the hardcoded variant is the fastest and the best, can somebody do a bit of porting my script to C and at least show me how to start? I do not programm in C but i can copy/paste stuff from the internet. I liked dwm because my script is doing the job really well but i'm tired of patching it and some options (border overlap) is not present in dwm so my choice is monsterwm (i like the idea etc).
Maybe i could use conky to display it and that sounds like the easiest way to do that but i guess i'm wrong. I tend to use the lightest apps so i would appreciate some advices
Thank you in advance.
Offline
I'm new to tiling WMs, but after having experimented with eight of those listed in the Comparison of Tiling Window Managers chart found in the wiki, this tiler has quickly become my favorite.
Thanks to all for your work on it!
oz
Offline
I know that i asked before but i need someone to help me to use my script (plain version of my script) in monsterwm with some bar. What i need is to make the way it is coded in script but hardcoded version of it (in C) could do the trick as long as i can set time for refreshing stats. Atm i plan to update my script and use "sleep $timeout" so i can refresh all stats in desired period od time..
This should work for use with Bar, but I didn't test it. Read up on bar to see how you configure it. You should also looke here for more examples on how you can output monsterwm to other panel types and hack one to your own needs.
#!/bin/bash
keyboard_indicator() {
if [ ! -z "$(setxkbmap -query | grep "layout" | awk '{print $2}' )" ]
then
echo -e "\uE014 \x02$(setxkbmap -query | grep "layout" | awk '{print $2}' )\x01"
else
echo -e "\uE014 \x01??\x01"
fi
}
battery_status(){
ac="$(awk '{ gsub(/%|%,/, "");} NR==1 {print $4}' <(acpi -V))"
on="$(grep "on-line" <(acpi -V))"
if [ -z "$on" ] && [ "$ac" -gt "15" ]; then
echo -e "\uE04F \x02$ac%\x05 |\x01"
elif [ -z "$on" ] && [ "$ac" -le "15" ]; then
echo -e "\uE04F \x05n/a\x05 |\x01"
else
echo -e "\uE023 \x02$ac%\x05 |\x01"
fi
}
free_mem(){
used_mem="$(awk '/^-/ {print $3}' <(free -m))"
free_mem="$(awk '/^-/ {print $4}' <(free -m))"
if [ "$free_mem" -gt "$used_mem" ]
then
echo -e "\uE037 \x02$used_mem\x05 MB |\x01"
else
echo -e "\uE037 \x06$used_mem\x05 MB |\x01"
fi
}
# CPU line courtesy Procyon:https://bbs.archlinux.org/viewtopic.php?pid=874333#p874333
cpu_usage(){
read cpu a b c previdle rest < /proc/stat
prevtotal=$((a+b+c+previdle))
sleep 0.5
read cpu a b c idle rest < /proc/stat
total=$((a+b+c+idle))
cpu_usage="$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))"
if [ "$cpu_usage" -gt "50" ]; then echo -e "\uE031 \x06$cpu_usage%"; fi
if [ "$cpu_usage" -le "50" ]; then echo -e "\uE031 \x01$cpu_usage%"; fi
}
cpu_speed() {
core_speed="$(grep "cpu MHz" /proc/cpuinfo | awk '{ print $4 }' )"
echo -e "\x05$core_speed |\x01"
}
hdd_space(){
hdd_space="$(df -P | sort -d | awk '/^\/dev/{s=s (s?" ":"") $5} END {printf "%s", s}')"
echo -e "\uE008 \x01$hdd_space\x05 |\x01"
}
# original: https://bitbucket.org/jasonwryan/workstation/src/7c79a4574d84/scripts/speed.sh
net_speed () {
RXB=$(cat /sys/class/net/eth0/statistics/rx_bytes)
TXB=$(cat /sys/class/net/eth0/statistics/tx_bytes)
sleep 2
RXBN=$(cat /sys/class/net/eth0/statistics/rx_bytes)
TXBN=$(cat /sys/class/net/eth0/statistics/tx_bytes)
RXDIF=$(echo -e $((RXBN - RXB)) )
TXDIF=$(echo -e $((TXBN - TXB)) )
RXT=$(ifconfig eth0 | awk '/bytes/ {print $2}' | cut -d: -f2)
TXT=$(ifconfig eth0 | awk '/bytes/ {print $6}' | cut -d: -f2)
echo -e "\uE03A \x02$((RXDIF / 1024 / 2))\x01 \uE03B \x06$((TXDIF / 1024 / 2))\x05 |\x01"
}
time_and_date(){
time_and_date="$(date "+%H:%M %d%m%Y")"
echo -e "$time_and_date"
}
temperature(){
cpu_temp="$(sensors | grep "temp1" | cut -c16- | head -c 2)"
mb_temp="$(sensors | grep "temp2" | cut -c16- | head -c 2)"
echo -e "\uE00A \x02$cpu_temp\uE010 $mb_temp\uE010\x05 |\x01"
}
# Pipe to status bar
# [$(keyboard_indicator)]
output_info="$(net_speed) $(cpu_usage) $(cpu_speed) $(temperature) $(free_mem) $(hdd_space) $(battery_status) $(time_and_date) "
ff="/tmp/monsterwm.fifo"
[[ -p $ff ]] || mkfifo -m 600 "$ff"
# desktop names
dnames=("main" "web" "dev" "vm" "null")
# layout names
layouts=("Tile" "Monocle" "Bstack" "Grid" "Float")
# refresh every 3 seconds
while read -t 3 -r wmout || true; do
if [[ $wmout =~ ^(([[:digit:]]+:)+[[:digit:]]+ ?)+$ ]]; then
read -ra desktops <<< "$wmout" && unset r
# parse through information for each desktop
for desktop in "${desktops[@]}"; do
IFS=':' read -r d w m c u <<< "$desktop"
# If (w)indows are present on this desktop make fg color f1 else f7
((w)) && fg="\\f1" || fg="\\f7"
# If this desktop is the (c)urrently focused one... or...
# m is the tiling (m)ode
((c)) && fg="\\f2" lc="\\u2" llabel="${layouts[$m]}" || lc="\\u0"
# If window in desktop has an (u)rgent hint
((u)) && fg="\\f9"
# add all desktops to r variable
r+="$lc$fg ${dnames[$d]} "
done
fi
# \\l is the left side of the bar, \\r is right side of bar
echo "\\l$r - $layout\\r$output_info"
done < "$ff" | bar
monsterwm > "$ff"
Last edited by bslackr (2013-01-05 05:17:11)
Offline
do you use '\x01' and alike characters directly ?
on my terminal they just print garbage ..
are they intended to be replaced by a color indicator that the statusbar recognizes?
also the usage of sleep in cpu_usage and net_speed is ugly
and on net_speed, RXT and TXT vars are unused
a C program would probably be faster though I dont think it's worth the time spent there
bash or sh would be almost as fast if written properly
however, the sleep calls in the functions mentioned would make the script runtime at least 2,5 secs
.:[ git me! ] :.
Offline
btw, you are using bash. a '.sh' suffix is misleading
here is your script revised, with default 1 minute interval
https://gist.github.com/4462085
run as
$ sys_monitor dwm # for usage with dwm, or
$ sys_monitor | bar # for usage with the LemonBar :D
keep in mind this has nothing to do with showing desktop information.
your question and the script name do not mention such a thing, so I left it out.
if you want that then you should adapt the script as @bslackr did.
there is one bug I need to find how awk prints multibyte chars
ie the equivalent of shell's 'printf '%b\n' "\uXXXX"' for awk
Last edited by c00kiemon5ter (2013-01-05 15:41:22)
.:[ git me! ] :.
Offline
@cookie
It works! Thank you very much (i did not expected to fix whole script). That awk print i messing up with my bar: http://i.imgur.com/qvjWG.png
Btw, i'm not interested at all in workspace indicators. They are not useful to me.
p.s. This script looks strange. Did you had to fix so many lines of code just to make it to behave correctly with printf?
Last edited by kuraku (2013-01-06 02:06:26)
Offline
well, no, I rewrote it to be more efficient, because that's what you wanted, I guess..
awk printing %b cannot be fixed it seems. one has to enter the char directly.
ie, line 36 is
END { printf("%b %s%s%s", "\uE014", g, l, n) }'
to fix it use printf to get the character that "\uE014" represents
$ printf '%b' "\uE014"
and substiture %b with that char, so line 36 now becomes
END { printf(" %s%s%s", g, l, n) }'
I can do that for you tomorrow (I'll update the gist),
though it would be nice to have awk working like the shell's printf. sigh
.:[ git me! ] :.
Offline
Thank you again.
p.s. You dont have to finish script for me, i will try to do it on my own
[edit]
I could remove all awk scripts and just use one color for all things. That way, i will be able to display icons in bar.
@bslackr
It is not wokring, i must say. I tried something similar before but with no luck. That is why i'm asking this right now
Last edited by kuraku (2013-01-06 03:19:58)
Offline