Creating a variable list Pashua, OS X & Bash.

Posted by S1syphus on Stack Overflow See other posts from Stack Overflow or by S1syphus
Published on 2010-04-19T10:18:31Z Indexed on 2010/04/19 10:23 UTC
Read the original article Hit count: 384

Filed under:
|
|

First of all, for those that don't know pashua is a tool for creating native Aqua dialog windows.

An example of what a window config looks like is

# pashua_run()

# Define what the dialog should be like
# Take a look at Pashua's Readme file for more info on the syntax

conf="
# Set transparency: 0 is transparent, 1 is opaque
*.transparency=0.95

# Set window title
*.title = Introducing Pashua

# Introductory text
tb.type = text
tb.default = "HELLO WORLD"
tb.height = 276
tb.width = 310
tb.x = 340
tb.y = 44

if [ -e "$icon" ]
then
# Display Pashua's icon
conf="$conf
     img.type = image
     img.x = 530
     img.y = 255
     img.path = $icon"
fi

if [ -e "$bgimg" ]
then
# Display background image
conf="$conf
      bg.type = image
      bg.x = 30
      bg.y = 2
      bg.path = $bgimg"
fi

pashua_run "$conf"

echo "  tb  = $tb"

The problem is, Pashua can't really get output from stdout, but it can get arguments.

Following on from what Dennis Williamson posted here. What ideally it should do is generate an output file based on information from a text file, To executed in pashua_run ore add the pashua_run around the window argument:

 count=1
 while read -r i
 do
 echo "AB${count}.type = openbrowser"
 echo "AB${count}.label = Choose a master playlist file"
 echo "AB${count}.width=310"
 echo "AB${count}.tooltip = Blabla filesystem browser"
 echo "some text with a line from the file: $i"
 (( count++ ))
done < TEST.txt >> long.txt

SO the output is

 AB1.type = openbrowser
 AB1.label = Choose a master playlist file
 AB1.width=310
 AB1.tooltip = Blabla filesystem browser
 some text with a line from the file: foo

 AB2.type = openbrowser
 AB2.label = Choose a master playlist file
 AB2.width=310
 AB2.tooltip = Blabla filesystem browser
 some text with a line from the file: bar

 AB3.type = openbrowser
 AB3.label = Choose a master playlist file
 AB3.width=310
 AB3.tooltip = Blabla filesystem browser
 some text with a line from the file: dev

 AB4.type = openbrowser
 AB4.label = Choose a master playlist file
 AB4.width=310
 AB4.tooltip = Blabla filesystem random

So if there is a clever way to get the output of that and place it into pashua run would be cool, on the fly: I.E load te contents of TEST.txt and generate the place it into pashua_run, I've tried using cat and opening the file... but because it's in Pashua_run it doesn't work, is there a smart way to break out then back in?

Or the second way which I was thinking, was create get the output then append it into the middle text file containing the pashua runtime, then execute it, maybe slightly hacky, but I would imagine it will do the job.

Any ideas?

++ I know I probably could make my life a lot easier, by doing this in actionscript and cocoa, although at present don't have time for such a learning curve, although I do plan to get round to it.

© Stack Overflow or respective owner

Related posts about bash

Related posts about osx