Click to See Complete Forum and Search --> : Um... is there a way to store variables between runs without using an external file?


Wallex
10-20-2002, 11:18 PM
Well... enough secrecy. I am trying to write a bash script that will give me a custom console beep (one that will accept the parameters volume, pitch and duration), but I don't know how to get X's bell current volume/pitch/duration, so I was thinking of storing those values myself (because if I don't, then all system beeps will default to whatever the last call of my script set them to). Since the script is a text file itself, i was wondering if there was a way to store the 'default' values on it (but not hardcoded as the user should be able to change them using --set as a parameter)? Or am I forced to use an auxiliary external text file to store these values?
It would be even better if I could get the bell properties from x... but xset is only for setting values, and reading man X takes forever and leads me nowhere.

bwkaz
10-21-2002, 02:11 PM
Did you read the man page for xset? ;)

$ xset q
Keyboard Control:
auto repeat: on key click percent: 0 LED mask: 00000000
auto repeat delay: 660 repeat rate: 25
auto repeating keys: 00ffffffdffffbbf
fa9fffffffdfe5ff
ffffffffffffffff
ffffffffffffffff
[b]bell percent: 50 bell pitch: 400 bell duration: 100
Pointer Control:
acceleration: 2/1 threshold: 4
Screen Saver:
prefer blanking: yes allow exposures: yes
timeout: 600 cycle: 600
Colors:
default colormap: 0x20 BlackPixel: 0 WhitePixel: 16777215
Font Path:
/usr/X11R6/lib/X11/fonts/local/,/usr/X11R6/lib/X11/fonts/misc/,
/usr/X11R6/lib/X11/fonts/75dpi/:unscaled,/usr/X11R6/lib/X11/fonts/100dpi/:unscaled,
/usr/X11R6/lib/X11/fonts/Type1/,/usr/X11R6/lib/X11/fonts/Speedo/,
/usr/X11R6/lib/X11/fonts/75dpi/,/usr/X11R6/lib/X11/fonts/100dpi/
Bug Mode: compatibility mode is disabled
DPMS (Energy Star):
Standby: 1200 Suspend: 1800 Off: 2400
DPMS is Disabled
Font cache:
hi-mark (KB): 1024 low-mark (KB): 768 balance (%): 70
[bilbo@beta predictors]$ :p

Wallex
10-21-2002, 02:35 PM
Oh oops. I guess I'll have to grep the output of xset -q to set the variables to what I want. I didn't think about that before.... well thanks!
Now it's time to learn about the famous grep... and to think I've never used it until now.
(any help on how to use grep to catch those values would be appreciated, altough right now that's what I am gonna go try to learn by myself)

TacKat
10-21-2002, 02:58 PM
xset q | grep "bell"

Then just parse that line.

Wallex
10-21-2002, 03:08 PM
Yep that's as far as I got on my own. The man for grep says that it is used to grab lines that match a pattern, so I assume that's as far as Grep goes? I can't use it to get just words and stuff like that, right? Well, that's what the man says anyway. About parsing... well, I guess this is a different issue, I'll go recheck the NHFs as there should probably be something in those about it.. afterall, parsing is bash's part, not grep's. Thanks for the info once more.

uptimenotifier
10-21-2002, 05:55 PM
For parsing text with a guaranteed format, try awk:

BELLDATA=$(xset q|grep bell)
echo $BELLDATA | awk '{print $3}' # volume
50
echo $BELLDATA | awk '{print $6}' # pitch
400
echo $BELLDATA | awk '{print $9}' # duration
100