wmhdplop: Fix GCC 4.7 FTBFS -Wl needs to have values passed to it so that it can...
[dockapps.git] / wmmenu / example / extract_icon_back
blob463f8daba71c0af544386cb1732446b4babb4d59
1 #!/usr/bin/awk -f
2 # Usage:
3 # extract_icon_back [<default pixmap name>]
4 # Description:
5 # Uses WindowMaker's getstyle command to extract the icon pixmap from
6 # preferences, and print it.
7 # If the name returned by getstyle is not absolute, the right pixmap path
8 # is supposed to be declared in wmmenu's defaults file.
9 # If no pixmap is found in WindowMaker's preferences (f.e. in case of
10 # pixmap-less gradient), the string provided as command line argument is
11 # used instead (and is possibly empty or unspecified).
12 # NB: This script expects a POSIX / X/Open compatible AWK. Be aware that
13 # some GNU awk versions do not fulfill this requirement.
15 BEGIN {
16 if (1 in ARGV) {
17 Name=ARGV[1]
18 delete ARGV[1]
20 ARGC=0
22 Command="getstyle"
23 IconBackLine=""
25 # Search first line marked "IconBack"
26 while (Ok = ((Command | getline) == 1)) {
27 if ($1 == "IconBack") {
28 IconBackLine=$0
29 break
32 ReturnDefaultIfNot(Ok)
34 # Accumulate while not closed
35 while (IconBackLine !~ /\);$/) {
36 Ok = ((Command | getline) == 1)
37 if (! Ok) break
38 IconBackLine=IconBackLine $0
40 ReturnDefaultIfNot(Ok)
42 # finished
43 close(Command)
45 # analyze what we have: split on '= (' and ', "' or ', '
46 FS="(, ([\"]?))|(= \()"
47 $0=IconBackLine
48 TextureType=$2
49 if(TextureType == "spixmap" || TextureType ~ /^t[hvd]gradient$/) {
50 Name=$3
51 sub(/[""]$/,"",Name)
53 print Name
56 function ReturnDefaultIfNot(ok) {
57 if (! ok) {
58 print Name
59 exit 0