Tiny Core Linux

Tiny Core Base => TCB Tips & Tricks => Topic started by: MakodFilu on February 20, 2009, 04:55:37 AM

Title: Quick tricks, calendar, dirty image viewer
Post by: MakodFilu on February 20, 2009, 04:55:37 AM
a) Just click anywhere in your desktop for the pop-up menu, select Run command and input the following:

aterm -title Calendar --geometry 40x18 -e dialog --no-cancel --calendar "Use cursor keys to navigate" 0 38

Voilá! A browsable calendar.


b)  Create a text file named background-viewer.sh somewhere (i. e. your home directory):
Code: [Select]
#!/bin/sh
for x in /opt/.backgrounds/*.[jJ][pP]*[gG]
do
  echo \<img src=\"$x\" /\> >> ~/backgrounds.htm
done
help ~/backgrounds.htm

cp your photos to /opt/.backgrounds  (note the dot) and you are set, an image viewer, gmail style. Works with .bmp and .png too, just edit the dedicated line.


c) rm /usr/bin/unlzma    # The unlzma applet is not in busybox anymore.

d) update syslinux. The bundled version behave funny when splash screens are present.
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: mikshaw on February 20, 2009, 07:35:20 AM
I had no idea there was a built-in calendar in dialog.  Nice.

I've been using a similar (less dirty) html generator to list and view animated gifs, since most Linux image viewers don't show the animation. Note it relies on CSS and iframe support, and has a couple of minor things customized to my system.
Code: [Select]
cat << EOF > Gifs.html

<html>
<head>
<title>GIF Images</title>
</head>
<style type="text/css">
a { font-family: verdana, arial, helvetica, sans-serif; font-size: 10;
color: #000000; text-decoration: none; padding: 2px; line-height: 2em;
border-style: solid; border-width: 1px; border-color: #DDDDDD }
a:hover { border-color: #000000 }
</style>
<body>
<iframe name="picture" frameborder="0" width="100%" height="360" src="000.jpg"></iframe>
<hr/>

EOF

for i in *.[Gg][Ii][Ff]; do
name=`echo "$i"|sed 's/\.[Gg][Ii][Ff]$//'`
size=`ls -lh "$i" | awk '{print $5}'`
echo "<a href=\"$i\" target=\"picture\" title=\"$i - $size\">$name</a>" >>Gifs.html
done
echo "</body></html>" >>Gifs.html
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: tobiaus on February 20, 2009, 02:48:03 PM
using the help viewer is inspired, though :) i just noticed it yesterday.
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: MakodFilu on February 23, 2009, 05:48:06 AM
That's it, that is the trick. No .tce nor .tcz needed.

Unfortunately, animated gif don't work, not even CSS. However, borrowing from mikshaw script:

Code: [Select]
#!/bin/sh
cat << EOF > ~/backgrounds.html
<html><head><title>Available backgrounds</title>
</head>
<body>
EOF

for x in /opt/.backgrounds/*.[gGpPbBjJ][iInNmMpP]*[fFpPgG]
do
  echo \<img src=\"$x\" /\>\<hr /\> >> ~/backgrounds.html
done
echo "</body></html>" >>~/backgrounds.html

help ~/backgrounds.html

Now it can show all your available wallpapers for you to choose. Beware, the code as it is would also load .pig files, so take care not to make this code look even dirtier by misplacing files in /opt/.backgrounds (((:
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: ^thehatsrule^ on March 02, 2009, 12:01:00 AM
If you are worried about that, you could use something like this instead:
Code: [Select]
for x in `ls -1 /opt/.backgrounds/ | grep -i  "\.\(gif\|png\|bmp\|jpg\|jpeg\)" `
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: jpeters on March 02, 2009, 02:16:27 AM
If you are worried about that, you could use something like this instead:
Code: [Select]
for x in `ls -1 /opt/.backgrounds/ | grep -i  "\.\(gif\|png\|bmp\|jpg\|jpeg\)" `

needs a "*" (edit: don't think "-l" is necessary :) )
Code: [Select]
for x in `ls  /opt/.backgrounds/* | grep -i  "\.\(gif\|png\|bmp\|jpg\|jpeg\)" `
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: MakodFilu on March 02, 2009, 07:03:26 AM
I think I should open the regex book I have and start reading it once and for all (: (or twice, or...)
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: ^thehatsrule^ on March 02, 2009, 02:32:47 PM
needs a "*" (edit: don't think "-l" is necessary :) )
Code: [Select]
for x in `ls  /opt/.backgrounds/* | grep -i  "\.\(gif\|png\|bmp\|jpg\|jpeg\)" `
Actually, the * and the -1 (note: it's a one) are not needed.  I usually use -1 by default so I can set IFS, etc if the paths might contain spaces.
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: jpeters on March 02, 2009, 03:46:21 PM
needs a "*" (edit: don't think "-l" is necessary :) )
Code: [Select]
for x in `ls  /opt/.backgrounds/* | grep -i  "\.\(gif\|png\|bmp\|jpg\|jpeg\)" `
Actually, the * and the -1 (note: it's a one) are not needed.  I usually use -1 by default so I can set IFS, etc if the paths might contain spaces.

It doesn't work without the "*" for me. 
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: ^thehatsrule^ on March 08, 2009, 04:09:53 PM
Odd - globbing shouldn't be needed.  What kind of setup/environment do you have?
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: tshandy33 on March 23, 2009, 10:51:46 AM
I followed the advice for accessing the calendar, but my screen just blinked (I think showing the calendar), but then the terminal closed. How do I get it to persist?
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: jpeters on March 23, 2009, 04:24:00 PM
Odd - globbing shouldn't be needed.  What kind of setup/environment do you have?

Sorry I missed see your question.  Without the "*" it omits the path.....(.necessary because backgrounds.html is stored in $HOME)  
Title: Re: Quick tricks, calendar, dirty image viewer
Post by: tobiaus on March 23, 2009, 05:06:16 PM
I followed the advice for accessing the calendar, but my screen just blinked (I think showing the calendar), but then the terminal closed. How do I get it to persist?

are you using the latest version of tc? i just tried it in tc 1.0, i think busybox has been updated since then. make certain you typed everything exactly, including the 0 38. normally i would suggest putting the part after -e in double quotes and adding && read, but since "use navigation commands" is in quotes you'll need to give more information, like whether you're trying to run this from the jwm menu and what version of tc.