Re: FVWM: Locales problem in a menu script
I see something new. When I start alsaplayer from a terminal, and issue the volume control command from another term, the program understand well both 0.5 and 0,5. But not when I start it from my menu. Dominique Le Thu, 28 Sep 2006 13:20:32 +0200, Dominique Michel [EMAIL PROTECTED] a écrit : Hi, I am on gentoo and I have done a menu script to have an alsaplayer control in the panel. I modified some fvwm-crystal scripts for that. The problem is at I use french locales: LANG=fr_CH.UTF-8 LANGUAGE=fr_CH.UTF-8 LC_ALL=fr_CH.UTF-8 and when I change to English locales, the volume and the speed control stop to work correctly. I have the following code: In Mixer-alsaplayer: DestroyMenu /Volume AddToMenu /Volume + 0 db% Mixer-Volume '1,0' + -3 db% Mixer-Volume '0,707' + -6 db% Mixer-Volume '0,5' + -12 dB% Mixer-Volume '0,25' + -18 db% Mixer-Volume '0,125' + -24 db% Mixer-Volume '0,0625' + 0 Mixer-Volume '0,0' DestroyFunc Mixer-Volume AddToFunc Mixer-Volume + I Exec exec alsaplayer --volume $0 In Music-alsaplayer: DestroyFunc /Music-generator AddToFunc /Music-generator + I DestroyMenu recreate /Music + I AddToMenu /Music '$[gt.Volume]' Popup /Volume The problem is at when I change to English locales, alsaplayer want to get . as decimal character, not a , I try to change the code as follow: DestroyFunc Mixer-Volume AddToFunc Mixer-Volume + I SetEnv x $0 + I PipeRead echo SetEnv y $(( $[x]/100 )) + I Exec exec xmessage x: $[x] + I Exec exec xmessage y: $[y] + I Exec exec $[A_Player] --volume $[y] DestroyMenu /Volume AddToMenu /Volume + 0 db% Mixer-Volume '100' + -3 db% Mixer-Volume '707000' + -6 db% Mixer-Volume '50' + -12 dB% Mixer-Volume '25' + -18 db% Mixer-Volume '125000' + -24 db% Mixer-Volume '62500' + -30 db% Mixer-Volume '31250' + -36 db% Mixer-Volume '15625' + 0 Mixer-Volume '0' But the shell output integer number in y, it mean only 1 or 0. I try this too: + I PipeRead echo SetEnv y $(( $[x]/100|bc-l )) but it work the same, I get only 1 or 0 in y. And it is even worse, because when I run $ echo 50/100|bc -l the shell output is always .5000 and that even when I use the french locales. Is it possible to get this script to work in any locale case? Dominique
Re: FVWM: Locales problem in a menu script
On Thu, 28 Sep 2006 13:20:32 +0200 Dominique Michel [EMAIL PROTECTED] wrote: DestroyFunc Mixer-Volume AddToFunc Mixer-Volume + I SetEnv x $0 + I PipeRead echo SetEnv y $(( $[x]/100 )) + I Exec exec xmessage x: $[x] + I Exec exec xmessage y: $[y] + I Exec exec $[A_Player] --volume $[y] The above can certainly be changed such that: DestroyFunc Mixer-Volume AddToFunc Mixer-Volume + I PipeRead 'echo exec exec $[A_PLAYER] --volume $(($0/10))' Note that if you (as I do), have ExecUseShell to use zsh, then you get arithmetic floting-point stuff for free. ;) But the shell output integer number in y, it mean only 1 or 0. It will if you use bash, because that doesn't support floating-point arithmetic. And it is even worse, because when I run $ echo 50/100|bc -l the shell output is always .5000 That's not the shell outputting that -- that's simply the result from the command bc. and that even when I use the french locales. Is it possible to get this script to work in any locale case? I am not even understanding how this is a locale-specific issue. -- Thomas Adam
Re: FVWM: Locales problem in a menu script
On 9/28/06, Thomas Adam [EMAIL PROTECTED] wrote: On Thu, 28 Sep 2006 13:20:32 +0200 Dominique Michel [EMAIL PROTECTED] wrote: Is it possible to get this script to work in any locale case? I am not even understanding how this is a locale-specific issue. Though I haven't tested, this might comes from the fact that floating number are to be displayed with a comma instead of a dot with French locale. -- Julien Guertault
Re: FVWM: Locales problem in a menu script
Dominque As Thomas said, it is due to the output of BC. Tou should try to get the 'bc' command 'scale=4' in there somewhere. On 9/28/06, Dominique Michel [EMAIL PROTECTED] wrote: I see something new. When I start alsaplayer from a terminal, and issue the volume control command from another term, the program understand well both 0.5 and 0,5. But not when I start it from my menu. Dominique Le Thu, 28 Sep 2006 13:20:32 +0200, Dominique Michel [EMAIL PROTECTED] a écrit : Hi, I am on gentoo and I have done a menu script to have an alsaplayer control in the panel. I modified some fvwm-crystal scripts for that. The problem is at I use french locales: LANG=fr_CH.UTF-8 LANGUAGE=fr_CH.UTF-8 LC_ALL=fr_CH.UTF-8 and when I change to English locales, the volume and the speed control stop to work correctly. I have the following code: In Mixer-alsaplayer: DestroyMenu /Volume AddToMenu /Volume + 0 db% Mixer-Volume '1,0' + -3 db% Mixer-Volume '0,707' + -6 db% Mixer-Volume '0,5' + -12 dB% Mixer-Volume '0,25' + -18 db% Mixer-Volume '0,125' + -24 db% Mixer-Volume '0,0625' + 0 Mixer-Volume '0,0' DestroyFunc Mixer-Volume AddToFunc Mixer-Volume + I Exec exec alsaplayer --volume $0 In Music-alsaplayer: DestroyFunc /Music-generator AddToFunc /Music-generator + I DestroyMenu recreate /Music + I AddToMenu /Music '$[gt.Volume]' Popup /Volume The problem is at when I change to English locales, alsaplayer want to get . as decimal character, not a , I try to change the code as follow: DestroyFunc Mixer-Volume AddToFunc Mixer-Volume + I SetEnv x $0 + I PipeRead echo SetEnv y $(( $[x]/100 )) + I Exec exec xmessage x: $[x] + I Exec exec xmessage y: $[y] + I Exec exec $[A_Player] --volume $[y] DestroyMenu /Volume AddToMenu /Volume + 0 db% Mixer-Volume '100' + -3 db% Mixer-Volume '707000' + -6 db% Mixer-Volume '50' + -12 dB% Mixer-Volume '25' + -18 db% Mixer-Volume '125000' + -24 db% Mixer-Volume '62500' + -30 db% Mixer-Volume '31250' + -36 db% Mixer-Volume '15625' + 0 Mixer-Volume '0' But the shell output integer number in y, it mean only 1 or 0. I try this too: + I PipeRead echo SetEnv y $(( $[x]/100|bc-l )) but it work the same, I get only 1 or 0 in y. And it is even worse, because when I run $ echo 50/100|bc -l the shell output is always .5000 and that even when I use the french locales. Is it possible to get this script to work in any locale case? Dominique -- Met vriendelijke groeten / With kind regards Hans Voss --- google talk enabled I am looking for people to invite to Gmail. I have 96 invitations left.
Re: FVWM: Locales problem in a menu script
On Thu, 28 Sep 2006, Dominique Michel wrote: Another way will be to test the locale in use, and sed the value to change the point against a comma when needed. But I have no idea where I can test the locale. I have never played with locales, quite hate them and happily stick to the C locale, but shouldn't be there an environment variable to test OR CHANGE, and could one not bracket such setenv in a subshell like (setenv =yyy ; command) ? I've used the trick for timezones, e.g. to know the time in Iceland one could (setenv TZ :/usr/share/zoneinfo/Atlantic/Reykjavik ; date) I do that (in sh syntax because of the SSI include directives) e.g. in http://sax.iasf-milano.inaf.it/~lucio/WWW/Personal/timezones.html !--#exec cmd=TZ=:/usr/share/zoneinfo/Atlantic/Reykjavik ; export TZ ; date-- Lucio Chiappetti - INAF/IASF - via Bassini 15 - I-20133 Milano (Italy) For more info : http://www.iasf-milano.inaf.it/~lucio/personal.html
Re: FVWM: Locales problem in a menu script
On 9/28/06, Dominique Michel [EMAIL PROTECTED] wrote: scale is for limiting the number of decimals, but the problem is the comma or the point. Alsaplayer want a comma with my french locale, and if it is a point, it accept only the leading 1 or 0, but nothing after. Another way will be to test the locale in use, and sed the value to change the point against a comma when needed. But I have no idea where I can test the locale. hmm, this sounds like your X and terminal locale are not consistant. The sed trick would probably work but would really be an ugly workaround. Maybe you can try forcing it during your call. I don't remember the way, but I think setting environment variables has been discussed already on this ML. -- Julien Guertault
Re: FVWM: Locales problem in a menu script
Le Thu, 28 Sep 2006 17:21:53 +0200 (CEST), Lucio Chiappetti [EMAIL PROTECTED] a écrit : On Thu, 28 Sep 2006, Dominique Michel wrote: Another way will be to test the locale in use, and sed the value to change the point against a comma when needed. But I have no idea where I can test the locale. I have never played with locales, quite hate them and happily stick to the C locale, but shouldn't be there an environment variable to test OR CHANGE, and could one not bracket such setenv in a subshell like (setenv =yyy ; command) ? I read something on the perl website when searching a solution for this script. The problem with the locales is at it is no one single normalisation but few normalisations. No matter, I find something that work when reading the files in /usr/share/fvwm-crystal. I done 2 sections in Mixer-alsamixer: DestroyFunc Mixer-VolumeFr AddToFunc Mixer-VolumeFr + I Exec exec $[A_Player] --volume $0 DestroyFunc Mixer-VolumeEn AddToFunc Mixer-VolumeEn + I Exec exec $[A_Player] --volume $0 DestroyMenu /VolumeFr AddToMenu /VolumeFr + 0 db% Mixer-VolumeFr '1,0' .. DestroyMenu /VolumeEn AddToMenu /VolumeEn + 0 db% Mixer-VolumeEn '1.0' .. And a test in Music-alsaplayer: Test (EnvMatch LANG fr_*.*) + I AddToMenu /Music '$[gt.Volume]' Popup /VolumeFr Test (!EnvMatch LANG fr_*.*) + I AddToMenu /Music '$[gt.Volume]' Popup /VolumeEn Thank you all anyway, it would have take more time without this discussion. Dominique I've used the trick for timezones, e.g. to know the time in Iceland one could (setenv TZ :/usr/share/zoneinfo/Atlantic/Reykjavik ; date) I do that (in sh syntax because of the SSI include directives) e.g. in http://sax.iasf-milano.inaf.it/~lucio/WWW/Personal/timezones.html !--#exec cmd=TZ=:/usr/share/zoneinfo/Atlantic/Reykjavik ; export TZ ; date-- Lucio Chiappetti - INAF/IASF - via Bassini 15 - I-20133 Milano (Italy) For more info : http://www.iasf-milano.inaf.it/~lucio/personal.html