Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Fri 18 Apr 2014, 21:55
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Desktop
simple icon tray
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 8 [114 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8 Next
Author Message
jamesbond

Joined: 26 Feb 2007
Posts: 1875
Location: The Blue Marble

PostPosted: Sat 14 Apr 2012, 01:16    Post subject:  

This is good stuff, archived for future use ...
_________________
Fatdog64, Slacko and Puppeee user. Puppy user since 2.13
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Sun 15 Apr 2012, 00:00    Post subject:  

technosaurus wrote:
@seaside - cool - the stripped down svgs I posted worked in an older wary with gtk 2.20 so it seemed safe - glad to see it being used


technosaurus,

Probably not too useful with sit being killed each time before a new icon was shown. So I changed the stock-ticker to update by copying over the new icon instead and added a right-click stop.

Regards,
s
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4134

PostPosted: Sun 03 Jun 2012, 22:29    Post subject:  

OK, I think I have inotify figured out - pretty simple really and would eliminate the need for update times. Can any C coders check this before I try and merge it into a callback? I am thinking it may be more straight forward to do this per file instead of per directory though.

usage:
myinotifyd /monitor/this/directory
Code:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/inotify.h>

#define EVENT_SIZE  ( sizeof (struct inotify_event) )
#define EVENT_BUF_LEN     ( 1024 * ( EVENT_SIZE + 16 ) )

int main(int argc, char** argv)
{
  int length, i, fd, watch;
  char buffer[EVENT_BUF_LEN];

fd = inotify_init();

if ( fd < 0 ) perror( "inotify init failed" );

/* check if argv[1] is a directory */

watch = inotify_add_watch( fd, argv[1], IN_CREATE | IN_DELETE | IN_MODIFY | IN_MOVED_FROM | IN_MOVED_TO | IN_ATTRIB );

while (1){
i=0;
length = read( fd, buffer, EVENT_BUF_LEN );
if ( length < 0 ) perror( "reading inotify fd" );

  while ( i < length ) {
   struct inotify_event *event = ( struct inotify_event * ) &buffer[ i ];
     if ( event->len ) {
      if (event->mask & IN_ATTRIB)printf("%s Metadata changed\n",event->name);
      if (event->mask & IN_CREATE)printf("%s created in watched directory\n",event->name);
      if (event->mask & IN_DELETE)printf("%s deleted from watched directory\n",event->name);
      if (event->mask & IN_MODIFY)printf("%s was modified\n",event->name);
      if (event->mask & IN_MOVED_FROM)printf("%s moved out of watched directory\n",event->name);
      if (event->mask & IN_MOVED_TO)printf("%s moved into watched directory\n",event->name);
    }
    i += EVENT_SIZE + event->len;
  }
}

inotify_rm_watch( fd, watch );
close( fd );

}

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4134

PostPosted: Mon 11 Jun 2012, 22:17    Post subject:  

so here it is - figured out how to make it update only when a file changes using some pretty hacky inotify and builtin gdk ops. I am going to call this one sit2 since it is significantly different in that it no longer uses a refresh time at all and now executes the right and left click commands directly (no need to keep a shell open to pipe the output through)
Code:
#include <sys/inotify.h>
#include <gtk/gtk.h>
#define EVENT_SIZE  ( sizeof (struct inotify_event) )
#define EVENT_BUF_LEN     ( 1024 * ( EVENT_SIZE + 16 ) )
void leftclick(GtkStatusIcon *si, gpointer s){popen(s,"r");} /* exec s */
void rightclick(GtkStatusIcon *si, guint b,guint a_t, gpointer s){popen(s,"r");}
void refresh(gpointer si, gint fd, GdkInputCondition c){   char buffer[EVENT_BUF_LEN];
   read( fd, buffer, EVENT_BUF_LEN ); /* we are just clearing it & don't care what event type */
   gtk_status_icon_set_from_file(si,gtk_status_icon_get_title(si));} /* redraws */
int main(int argc, char *argv[]){   GtkStatusIcon *si; int i=1, watch, fd;
gtk_init (&argc, &argv); /* loop through icon, tooltip, click messages */
while (i<argc) {   fd = inotify_init(); /* get file descriptor to write on if image changes */
   si = gtk_status_icon_new_from_file(argv[i]); /* get a status icon widget */
   gtk_status_icon_set_title(si,argv[i]); /* hack to store the image path */
   watch = inotify_add_watch( fd, argv[i++], IN_CREATE | IN_MODIFY | IN_MOVED_FROM );
   gdk_input_add( fd, GDK_INPUT_READ, refresh, si ); /* inotify fd is ready for reading, refresh */
   gtk_status_icon_set_tooltip_text(si,argv[i++]);
   g_signal_connect(G_OBJECT(si), "activate", G_CALLBACK(leftclick),(gpointer) argv[i++]);
   g_signal_connect(G_OBJECT(si), "popup-menu", G_CALLBACK(rightclick), (gpointer) argv[i++]);}
gtk_main ();}
sit2.tar.gz
Description 
gz

 Download 
Filename  sit2.tar.gz 
Filesize  2.18 KB 
Downloaded  406 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Wed 13 Jun 2012, 16:01    Post subject:  

technosaurus,

jJust tried it out and everything works nicely. Thanks.

I was wondering if it were possible to extend the inotify aspect to include monitoring for usb drive additions and removals.

Regards,
s
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4134

PostPosted: Wed 13 Jun 2012, 16:30    Post subject:  

It really wouldn't go with this project, but monitoring the /sys/block directory for IN_CREATE events would be a good place to start if you wanted to use this as a starting point, but it would be possible to just kill and restart sit for the added drive. There is already a program called inotifyd that does the monitoring and launching part. I would start there.
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Wed 13 Jun 2012, 17:33    Post subject:  

Technosaurus,

Thanks for the tip -
Code:
Usage: inotifyd PROG FILE1[:MASK].


That seems much easier than inotifywait with pipes and loops.

Regards,
s
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4134

PostPosted: Wed 13 Jun 2012, 17:37    Post subject:  

btw it inotifyd is available as busybox applet now too
_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4134

PostPosted: Sat 16 Jun 2012, 19:05    Post subject:  

I have these 217 MIT Licensed icons roughly adapted for use in shell scripts:
http://raphaeljs.com/icons/

... just the icons themselves for now, custom options (foregrounds, backgrounds, colors, text, etc..) can be added later.

my script itself is TPL
svgdraw.bz2
Description  usage:
svgdraw iconname
(output is iconname.svg in current working directory)
bz2

 Download 
Filename  svgdraw.bz2 
Filesize  73.62 KB 
Downloaded  364 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 5562
Location: Valåmoen, Norway

PostPosted: Sun 17 Jun 2012, 00:53    Post subject:  

Wrong thread, sorry
_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Sun 17 Jun 2012, 09:18    Post subject:  

Dear technosaurus,

That is a great little script with the icons. I modded it a bit to add a usage bit and made it possible to change colours from the command line. Also, run without parameters, the program spits out a somewhat formatted and sorted list of available icons. Those bits can be improved, but this is what a few minutes of hacking yielded Smile

With thanks and kind regards,
vovchik
svgdraw-col.tar.gz
Description 
gz

 Download 
Filename  svgdraw-col.tar.gz 
Filesize  84.63 KB 
Downloaded  394 Time(s) 
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 878

PostPosted: Sun 17 Jun 2012, 10:07    Post subject:  

technosaurus,

What a clever use of that javascript internet material. Well done.
Now possible to have a nice collection of icons at the ready on demand or easily pre-made with matching color schemes.

Thanks and regards,
s
(If Vovchik also works on it, you know it has to be good) Very Happy
This line was really great-
Code:
icons=`printf "%-20.20s %-20.20s %-20.20s\n" $(sed -n -e '/START/,/END/p' "$PROGDIR/$PROGNAME" | grep "=\"M" | cut -d'=' -f1 | sort)`
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Mon 18 Jun 2012, 07:17    Post subject:  

@ seaside: thanks Smile

Dear guys and gals,

I have really improved the input checking and other bits of this script. The icon list is now formatted nicely, and there is also a list for svg 'named colors'. I also changed a bit of the svg generation - modifying the viewBox and scaling so that it generates nominal 128px boxes and 128px objects. You cannot now try to use a non-existent icon or color - the program will tell you. There are two parameters (-i and -c) that will display icons and colors respectively. Have fun. I think technosaurus also deserves at least a few cold beers for his work.

With kind regards,
vovchik
svgdraw-col.tar.gz
Description 
gz

 Download 
Filename  svgdraw-col.tar.gz 
Filesize  86.28 KB 
Downloaded  393 Time(s) 
Back to top
View user's profile Send private message 
01micko


Joined: 11 Oct 2008
Posts: 7547
Location: qld

PostPosted: Mon 18 Jun 2012, 17:20    Post subject:  

Made a start with the temperature script.

http://murga-linux.com/puppy/viewtopic.php?p=635030#635030

_________________
Woof Mailing List | keep the faith Cool |
Back to top
View user's profile Send private message Visit poster's website 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Tue 19 Jun 2012, 06:08    Post subject:  

Dear puppians,

I can't seem to get enough of a good thing. Here is a BaCon port I just did of the SVG generating script discussed above. It takes forever to compile (several minutes), but it runs circles around bash (gets compiled by gcc). I compiled in Lucid, so that it should work on all recent puppies. I also UPX'd the binary, so that it is much smaller than the bash version (100k v. 241k), apart from being inherently faster. Have fun....

With kind regards,
vovchik

PS. Just unarchive and copy the binary to /usr/local/bin, for example. The source is also included. You need BaCon to compile, and don't think that the compiler is stuck in a loop. It will finish eventually.

PPS: UPDATED src and binary. 01micko picked up a little bug in my FIND routine. Kudos:)
bsvg-0.1a.tar.gz
Description 
gz

 Download 
Filename  bsvg-0.1a.tar.gz 
Filesize  188.62 KB 
Downloaded  354 Time(s) 

Last edited by vovchik on Tue 19 Jun 2012, 10:23; edited 1 time in total
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 8 [114 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7, 8 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Desktop
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0782s ][ Queries: 13 (0.0051s) ][ GZIP on ]