problem when using ls in gtkdialog..

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
hannysabbagh
Posts: 17
Joined: Sun 14 Apr 2013, 10:34

problem when using ls in gtkdialog..

#1 Post by hannysabbagh »

Hello.

i have wrote a command to list all gtk2 themes in /usr/share/themes:

ls -d /usr/share/themes/*/gtk-2.0 | awk -F"/gtk-2.0" '{print $1}'

the problem is when i try to put this command as an input command for comboboxtext, of course it will give me a Synatex error because of the '

so i tried to use a variable like $thing='{print $1}' , and in comboboxtext:

ls -d /usr/share/themes/*/gtk-2.0 | awk -F"/gtk-2.0" "$thing"

this way works very good on the terminal, but in gtkdialog it doesn't work, it gives me ls: write error: Broken pipe

any help ?
thanks.[/code]

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#2 Post by seaside »

hannysabbagh,

You can do it with a function -

Code: Select all

#!/bin/sh

theme_list() {
ls -d /usr/share/themes/*/gtk-2.0 | awk -F"/gtk-2.0" '{print $1}'
}

export -f theme_list

GTKDIALOG=gtkdialog
export MAIN_DIALOG='
<vbox>
  <hbox>
    <text>
      <label>Combobox:</label>
    </text>
    <comboboxtext>
      <variable>COMBOBOX</variable>
      <input>theme_list</input>
    </comboboxtext>
  </hbox>
  <hbox>
    <button ok></button>
    <button cancel></button>
  </hbox>
</vbox>
'

$GTKDIALOG --program=MAIN_DIALOG 
Cheers,
s

hannysabbagh
Posts: 17
Joined: Sun 14 Apr 2013, 10:34

#3 Post by hannysabbagh »

hello seaside.

i know that you can do that, but the problem is that i need only the theme name, not its full directory, like:"Crux,Adwitia.." not "/usr/share/themes/crux"...

thank you.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#4 Post by seaside »

hannysabbagh,

Perhaps this.

Code: Select all

ls -d /usr/share/themes/*/gtk-2.0 | awk -F"/" '{print $5}' 
Cheers,
s

EDIT: I'm not really sure what you're looking for because you could do this by " ls /usr/share/themes/".

hannysabbagh
Posts: 17
Joined: Sun 14 Apr 2013, 10:34

#5 Post by hannysabbagh »

Thank you my friend, it is now working correctly :)
Thanks.

Post Reply