Author Topic: zenity script  (Read 7602 times)

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
zenity script
« on: July 06, 2010, 09:21:11 AM »
The ls command in the script in the terminal will list the plymouth themes in the terminal, but running the script brings up an empty list box.

Code: [Select]
# temp folder
if [ ! -d $HOME/.config/tmp ]; then mkdir -p $HOME/.config/tmp; fi
LIST="$HOME/.config/tmp/lst01"

# delete old theme list
if [ -f "$LIST" ]; then rm -f "$LIST";fi

# create plymouth-theme list
THEMELIST=`ls -d /usr/share/plymouth/themes/*/*.plymouth`
for i in $THEMELIST; do echo $i | cut -d/ -f5 >> "$LIST";done

cd /tmp
echo 'XX=$(zenity --title "Select a Plymouth Theme" --text "Please select a plymouth theme or press Cancel to quit.\nNOTE: you must reboot to apply the new plymouth theme\!" --list --height 300 --radiolist --column "Select" --column "Plymouth Theme" ' > tt1

The error message in terminal is
Code: [Select]
ls: cannot access /usr/share/plymouth/themes/*theme: No such file or directory
cat: /root/.config/tmp/lst01: No such file or directory

I'm pretty sure I'm missing something obvious, but I can't see it. ::)


Offline tschommer

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1889
  • MLU and BLU (Bacon lovin' user)
Re: zenity script
« Reply #1 on: July 06, 2010, 09:54:01 AM »
Neal,

you specified the cut command with -f5, but the file names are in the 7th position (the 1st element preceeds the first "/").

When I try

Code: [Select]
echo "/usr/share/plymouth/themes/details/details.plymouth" | cut -d/ -f5
I get "themes", but when I specify

Code: [Select]
echo "/usr/share/plymouth/themes/details/details.plymouth" | cut -d/ -f7
it gives me the actual file names.

By the way - wouldn't the  basename command give you more flexibility? Just a thought  ;)

HTH

Torsten
Our defense is in the preservation of the spirit which prizes liberty as the heritage of all men, in all lands, everywhere."
Abraham Lincoln --September 11, 1858 Speech at Edwardsville, Illinois

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: zenity script
« Reply #2 on: July 06, 2010, 10:05:39 AM »
I made those changes, but the result is the same as before.

Could you write a basename script that would work? ??? I can't. ::) :( I wish I could.

Offline tschommer

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1889
  • MLU and BLU (Bacon lovin' user)
Re: zenity script
« Reply #3 on: July 06, 2010, 10:13:32 AM »
I think this should work:

Code: [Select]
for i in $THEMELIST; do basename $i >> "$LIST";done
Our defense is in the preservation of the spirit which prizes liberty as the heritage of all men, in all lands, everywhere."
Abraham Lincoln --September 11, 1858 Speech at Edwardsville, Illinois

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: zenity script
« Reply #4 on: July 06, 2010, 10:17:10 AM »
No. Same results. ???

Offline tschommer

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1889
  • MLU and BLU (Bacon lovin' user)
Re: zenity script
« Reply #5 on: July 06, 2010, 11:04:58 AM »
Hmm, strange. I got the file list saved correctly in $HOME/.config/tmp/lst01:

Code: [Select]
[torsten@schommer ~]$ cat .config/tmp/lst01
details.plymouth
PCLinuxOS.plymouth
text.plymouth
[torsten@schommer ~]

But I only got the script to work with a variable ($LST) containing the values (including the "FALSE" directive for the 1st column). Also, I haven't used zenity myself, so I only got it to work without the "echo ... >tty1".

The complete code (with a few comments added):

Code: [Select]
# temp folder
if [ ! -d $HOME/.config/tmp ]; then mkdir -p $HOME/.config/tmp; fi
LIST="$HOME/.config/tmp/lst01"

# delete old theme list
if [ -f "$LIST" ]; then rm -f "$LIST";fi

LST=""

# create plymouth-theme list
THEMELIST=`ls -d /usr/share/plymouth/themes/*/*.plymouth`

# include "FALSE" for the first column and the file name for the second one
for i in $THEMELIST; do LST="$LST FALSE `basename $i`";done

# save the list to the file specified above
echo $LST > $LIST

cd /tmp
XX=$(zenity --title "Select a Plymouth Theme" --text "Please select a plymouth theme or press Cancel to quit.\nNOTE: you must reboot to apply the new plymouth theme\!" --list --height 300 --radiolist --column "Select" --column "Plymouth Theme" $LST)

Hope this gives you something to work with.
Our defense is in the preservation of the spirit which prizes liberty as the heritage of all men, in all lands, everywhere."
Abraham Lincoln --September 11, 1858 Speech at Edwardsville, Illinois

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: zenity script
« Reply #6 on: July 06, 2010, 12:06:13 PM »
The script, so far, is attached. I changed the list part of the script to use what you posted, but I'm still getting the same errors.

Offline tschommer

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1889
  • MLU and BLU (Bacon lovin' user)
Re: zenity script
« Reply #7 on: July 06, 2010, 01:20:40 PM »
Neal,

one thing I noticed: you insert a "FALSE " in front of the file list, but a "FALSE " is already in the variable for each option (done in the for-loop => LST="$LST FALSE `basename $i`), so that shouldn't be needed. In my case the variable $LST contains:

Code: [Select]
FALSE details.plymouth FALSE PCLinuxOS.plymouth FALSE text.plymouth
You want to create a script /tmp/tt0, but I just can't figure out what it's supposed to contain (besides the #!/bin/bash and the ); at the end) - could you just give me an example for what /tmp/tt0 should look like?

Maybe you could also give me a hint where the currently used theme is stored, then maybe I could come up with something...?

We'll get to the bottom of this!  ;)

Torsten
Our defense is in the preservation of the spirit which prizes liberty as the heritage of all men, in all lands, everywhere."
Abraham Lincoln --September 11, 1858 Speech at Edwardsville, Illinois

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: zenity script
« Reply #8 on: July 06, 2010, 01:35:42 PM »
I guess I was trying to do the script similar to lxcursor. (attached)

Offline daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3729
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: zenity script
« Reply #9 on: July 06, 2010, 02:06:55 PM »
Hi Neal,
for what you need it?

The themes at last works for me perfectly...

Offline tschommer

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1889
  • MLU and BLU (Bacon lovin' user)
Re: zenity script
« Reply #10 on: July 06, 2010, 02:09:33 PM »
That's actually a pretty good example. Here's what I got (and it seems to work  ;))

Our defense is in the preservation of the spirit which prizes liberty as the heritage of all men, in all lands, everywhere."
Abraham Lincoln --September 11, 1858 Speech at Edwardsville, Illinois

Offline tschommer

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1889
  • MLU and BLU (Bacon lovin' user)
Re: zenity script
« Reply #11 on: July 06, 2010, 02:49:19 PM »
Neal,

I just made the following changes to the script so that only the theme name would be displayed (with the ".plymouth" suffix):

1. changed line 56 from
     
Code: [Select]
for i in $THEMELIST; do echo `basename $i` >> "$LIST";done    to
     
Code: [Select]
for i in $THEMELIST; do echo `basename ${i%.plymouth}` >> "$LIST";done
2. Removed the original line 73 to determine the directory name of the theme and added the ".plymouth" suffix for the soft link:
     
Code: [Select]
ln -fs /usr/share/plymouth/themes/$PLY_SELECT/$PLY_SELECT.plymouth $HOME/.plymouth/default
If I can help out any more I'll be glad to.

Torsten
Our defense is in the preservation of the spirit which prizes liberty as the heritage of all men, in all lands, everywhere."
Abraham Lincoln --September 11, 1858 Speech at Edwardsville, Illinois

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: zenity script
« Reply #12 on: July 06, 2010, 05:28:42 PM »
Thank you very much, Torsten! WooHoo! :D It appears to be working. I need to reboot to check, but the script is working as for as can be seen. :D Be back soon.

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: zenity script
« Reply #13 on: July 06, 2010, 05:29:51 PM »
Hi Neal,
for what you need it?

The themes at last works for me perfectly...

I'm trying to create a GUI for changing between plymouth boot themes.

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15845
  • LXDE! Coffee, Bacon and Cheesecake!
Re: zenity script
« Reply #14 on: July 06, 2010, 05:39:09 PM »
The theme didn't change. ??? ::) ???