simple icon tray

Window managers, icon programs, widgets, etc.
Message
Author
seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#46 Post by seaside »

Vovchik,

Wow. That work is a tribute to your tenacity and knowledge of imagery :!:

Thanks again,
s
(Now I know why I was wise enough to go on to something else :D )
EDIT: I did find that the cross icon didn't render

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#47 Post by technosaurus »

vovchik wrote:Dear seaside,

Thanks. Conversion is a royal pain in the arse. You have to ungroup the image in Inkscape (several times) and then use Item->Convert to paths for every object. I suppose this could be done algorithmically, but I did it the ugly manual way, with some preliminary programmed parsing to throw out prolix metadata and other unnecessary garbage. Nominal scaling is also another pain, but it is important to have one viewport for all icons of the same dimensions, particularly if you later want to convert to png or something else. It will save work later on. With the transform statement I have included, and the path data, you should now be able to use the data in bash or something else to make your own generator or gui.

With kind regards,
vovchik
... yeah, I've just been stringing only the d="..." from each path into the same one in a separate file and then pasting them back into my case statement using none of the rest of the svg metadata, rounding the numbers along the way... fairly reasonable success when they are all on the same scaling (too much math otherwise)

it was easier to replace "M", "C", and "L" with \nM \nC and \nL in geany (sed would have worked too but I wanted to _see_ it)
also replaced commas with spaces to help awk
this is the awk:

Code: Select all

awk '/^L/||/^M/{printf "%c %d,%d",$1,$2+0.5,$3+0.5}
/^C/{printf "%c %d,%d %d,%d %d,%d", $1, $2+0.5, $3+0.5, $4+0.5, $5+0.5, $6+0.5,$7+0.5}' infile >outfile
this rounding part _should_ cut the code size down quite a bit (as much as 80% reduction)
FYI, adding 0.5 and casting to int (%d) is a nifty rounding trick that works great (fast) in C also, though in C you would actually need to do: (int) (myfloat + 0.5) ... awk does that for us

here is another email icon
d="M 2,38 L 16,24 L 24,32 L 32,24 L 46,38 L 2,38 z M 0,8 L 14,22 L 0,36 L 0,8 z M 2,6 L 24,28 L 48,6 L 2,6 z M 48,8 L 34,22 L 48,36 L 48,8 z "[/list]
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

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

#48 Post by seaside »

vovchik,

Here's the reworked bsvg-gui for sit to go with your new gem.

Code: Select all

#!/bin/sh
#
# based on bash svgdraw by technosaurus (as
#         modded by vovchik) and raphaeljs by
#         Dmitriy Baranovskiy (copyright 2008
# LICENSE:   GPL3
# Iconics svgs added
# GUI seaside -requires sit2 and bsvg-0.1c.

for i in `bsvg -I`; do ICONS="$ICONS<item>$i</item>";done
for i in `bsvg -C`; do COLS="$COLS<item>$i</item>";done

 makeicon()  {
 bsvg $ICON  $LINE_COLOR  $FILL_COLOR ->/tmp/siticon.svg
 exit
 }
 export -f makeicon
 
 echo '<svg width="128" height="128" viewBox="0 0 128 128">
	<g transform="matrix(4.000000,0.000000,0.000000,3.637503,24.80000,5.999897)">
		<path style="fill:aliceblue;fill-rule:nonzero;stroke:aliceblue;fill-opacity:0.75;stroke-opacity:0.75;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;"
		d="M9.212,32c-2.359,0-4.719-0.898-6.52-2.691c-3.59-3.598-3.59-9.449,0-13.039l8.113-7.938 c0.461-0.465,0.727-1.102,0.727-1.785c0-0.68-0.266-1.32-0.742-1.805C9.798,3.75,8.181,3.754,7.181,4.746 C6.196,5.738,6.196,7.355,7.188,8.348L4.356,11.18C1.806,8.625,1.806,4.473,4.353,1.918c2.562-2.559,6.711-2.555,9.264-0.004 c1.242,1.238,1.922,2.887,1.922,4.637c0,1.75-0.68,3.395-1.922,4.629l-8.111,7.934c-2.02,2.016-2.02,5.328,0.02,7.363 c2.031,2.035,5.344,2.031,7.383,0c2.029-2.035,2.029-5.348,0-7.379l-1.422-1.414l4.35-4.348l2.828,2.828l-1.672,1.672 c2.266,3.562,1.852,8.359-1.258,11.469C13.937,31.102,11.571,32,9.212,32L9.212,32z" />
	</g>
</svg> ' >/tmp/siticon.svg

sit /tmp/siticon.svg &
 
export MAIN_DIALOG='
<vbox>
  <hbox>
    <text>
      <label>Icon Select::</label>
    </text>
    <combobox>
      <variable>ICON</variable>
      '"$ICONS"'
    </combobox>
  </hbox>
  <hbox>
    <text>
      <label>Line Color</label>
    </text>
    <combobox>
      <variable>LINE_COLOR</variable>
      '"$COLS"'
    </combobox>
  </hbox>
  <hbox>
    <text>
      <label>Fill Color</label>
    </text>
    <combobox>
      <variable>FILL_COLOR</variable>
      '"$COLS"'
    </combobox>
  </hbox>
  <hbox>
   <button ok>
      <action>makeicon</action>
   </button>
   <button cancel>
      <action>killall sit</action>
    <action>exit:</action>
   </button>
  </hbox>
 </vbox>
'

gtkdialog3 --program=MAIN_DIALOG
unset MAIN_DIALOG 
technosaurus

Code: Select all

awk '/^L/||/^M/{printf "%c %d,%d",$1,$2+0.5,$3+0.5}
/^C/{printf "%c %d,%d %d,%d %d,%d", $1, $2+0.5, $3+0.5, $4+0.5, $5+0.5, $6+0.5,$7+0.5}' infile >outfile 
Really "awksome" I think I'll have to go to a dark corner somewhere and try to recover :D

Amazing to have every likely icon quickly available in a simple easily recognizable image. Nicely done.

Regards,
s

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

bsvg updated (478 icons)

#49 Post by vovchik »

Dear guys,

I have been at it again. This is version 0.1d that now contains 478 icons. The "V-bk" ones are really good and useful. Please have a look. Technosaurus' email icon is also in there.

With kind regards,
vovchik

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#50 Post by technosaurus »

I had some goodies to post, but i got a little too inventive with my svg coding and deadlocked my system. Turns out that if you recursively include an image in itself viewnior starts trying to open it but goes into an endless loop, inkscapelite only goes down one layer so it is fine, and seamonkey will keep showing layer after layer but eventually deadlock the system. There was a difference if you had 2 copies that included each other (a.svg that includes b.svg and vice versa) compared to an image that includes itself (apparently some apps do detect that)

Here is close to what the example was if anyone wants to test their favorite viewer:

Code: Select all

<svg width="100%" height="100%"
     xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
  <circle cx="50%" cy="50%" r="50%" style="fill:red;opacity:0.05" />
  <image x="1%" y="1%" width="98%" height="98%" xlink:href="b.svg" />
</svg>
@vovchik/seaside: The SVG code appears to be progressing to the point where it is useful outside the tray. If you want to start a separate thread, let me know and I'll put a link in my initial post.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#51 Post by technosaurus »

here is some code that will allow it to also control the desktop background using a gtkrc file located at /usr/share/sit

I tried using a gtkiconview for desktop icons, (works fine, but gets a white bg) but I can't seem to set its background pixmap directly or at least transparent so that the window bg shows through... maybe setting the "selection-box-alpha" style property (already tried using style property to set base[NORMAL] and/or bg[NORMAL] to NULL, "None", but that didn't seem to work)
Attachments
sit3.pet
source is in /usr/share/sit
(3.61 KiB) Downloaded 640 times
Last edited by technosaurus on Mon 09 Jul 2012, 21:10, edited 1 time in total.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#52 Post by 01micko »

@techno..

Are you trying to get gtk icons on the desktop? Using gtkdialog?

I made a weather applet that worked at the time (somewhat broken now due to html changes) with a transparent background on the desktop, maybe there is a snippet in there that will help? http://www.murga-linux.com/puppy/viewto ... 629#598629

Maybe akash_rawal's applet could help?
Puppy Linux Blog - contact me for access

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#53 Post by technosaurus »

Not gtkdialog, just thought it would be nice to have it do desktop icons as well and the gtkiconview _seemed_ like the obvious choice, but it is (was?) hard-coded to draw a background color ... I just want it to copy from parent

apparently this is a long standing complaint
http://www.gtkforums.com/viewtopic.php? ... 9dd0#p7728
that may be fixed in gtk3?

see image below:
Attachments
bad-desk.png
(95.52 KiB) Downloaded 1147 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#54 Post by technosaurus »

I decided to drop the desktop handling parts until I find a good way to do icons, so redirected focus to making it cross platform (bsd and possibly windows) ... replaced inotify with gio functions an added a usage text
build with:
gcc `pkg-config gtk+-2.0 --cflags` sit.c -o sit -lgtk-x11-2.0

Code: Select all

#include <gtk/gtk.h>
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(GFileMonitor *monitor,	GFile *file, GFile *to_file, GFileMonitorEvent event, gpointer si){
	gtk_status_icon_set_from_file(si,g_file_get_path(file));} /* redraws twice ??? */

int main(int argc, char *argv[]){ 	GtkStatusIcon *si; char i=1; gtk_init (&argc, &argv);
if ( argc < 2 ) {g_print("usage\n%s /path/to/image left-action right-action ...\n",argv[0]);return 1; }
while (i<argc) {  /* loop through icon, tooltip, click messages */
	si = gtk_status_icon_new_from_file(argv[i]);
	g_signal_connect(g_file_monitor_file(g_file_new_for_path(argv[i++]), G_FILE_MONITOR_NONE, FALSE, NULL),
		"changed", G_CALLBACK(refresh),(gpointer) si);
	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 ();}
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#55 Post by 01micko »

Thought I better post this one, stuffed around with it awhile ago when I was playing with xpm.

http://colby.id.au/node/39 (ref)

Code: Select all

#!/bin/sh
# cpu usage as tray icon using SIT from technosaurus

[ ! -d /tmp/cpuicon ] && mkdir /tmp/cpuicon

cpu2svg() #again from techno
{
i=$1
FFAMILY=helvetica

T=16
[ "$i" = "100" ] && T=12
BG="#FF00FF" #hot pink (default)
	[ "$i" -le "10" ] && BG='#D7FFFF' #pale blue
	[[ "$i" -gt "10" && "$i" -le "25" ]] && BG="#00FFFF" #light blue
	[[ "$i" -gt "25" && "$i" -le "50" ]] && BG="#FFD7D7" #pale pink
echo '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <rect width="34"
     height="22"
     x="0"
     y="0"
     rx="3"
     ry="3"
     style="font-size:'${T}';fill:'$BG';fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"
     id="rect1" />
  <text
     x="0"
     y="18"
     style="font-size:'${T}';font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:'$FFAMILY';"
     id="text1">
    <tspan
       id="tspan1">'"${i}%"'</tspan>
  </text>
</svg>'	> /tmp/cpuicon/cpu.svg
}

cpuusage() #Paul Colby http://colby.id.au/node/39
{
PREV_TOTAL=0
PREV_IDLE=0
 
while true; do
  CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics.
  unset CPU[0]                          # Discard the "cpu" prefix.
  IDLE=${CPU[4]}                        # Get the idle CPU time.
 
  # Calculate the total CPU time.
  TOTAL=0
  for VALUE in "${CPU[@]}"; do
    let "TOTAL=$TOTAL+$VALUE"
  done
 
  # Calculate the CPU usage since we last checked.
  let "DIFF_IDLE=$IDLE-$PREV_IDLE"
  let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
  let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10"
  #echo -en "\rCPU: $DIFF_USAGE%  \b\b" # uncomment for commandline output
  cpu2svg $DIFF_USAGE
 
  # Remember the total and idle CPU times for the next check.
  PREV_TOTAL="$TOTAL"
  PREV_IDLE="$IDLE"
 
  # Wait before checking again.
  sleep 1
done
}
cpuusage &

sit 1000 /tmp/cpuicon/cpu.svg "cpu usage" "rxvt -e top" "pprocess" 2>/dev/null | \
while read LINE; do
case "$LINE" in
 *)exec $LINE &
 ;; 
esac
done
Puppy Linux Blog - contact me for access

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#56 Post by technosaurus »

01micko wrote:Thought I better post this one, stuffed around with it awhile ago when I was playing with xpm
excellent,

I am wondering how many of these applets could be cross platform. Obviously these ones that use Linux pseudo file systems won't. Doesn't one of our devs still build win32 apps (MU? maybe). If anyone has a windows, bsd or other non-linux environment, I'd be interested to know if A. It builds and B. If/how it works.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#57 Post by 01micko »

Here's the large version with menu right click and it works on the raspberry pi. Needs a font change with other arches, fatdog produced similar small fonts to the raspi with helvetica.

Note that your sit build script fails both in slacko and on the rpi (debian based pup). I'll post error messages later. I just used the basic link to gtk, nothing fancy

Code: Select all

#!/bin/sh
# cpu usage as tray icon using SIT from technosaurus

[ ! -d /tmp/cpuicon ] && mkdir /tmp/cpuicon

GUIHEIGT=162 #get this with xwininfo beforehand + taskbar height
HEIGHT=$(xwininfo -root | grep 'Height'| cut -f 2 -d ':')
WIDTH=$(xwininfo -root | grep 'Width'| cut -f 2 -d ':')
YDIM=`echo $(($HEIGHT - $GUIHEIGT))`
XDIM=`echo $(($WIDTH - 250))`
PROG=$(basename $0)

# htop||top
lclick()
{
	[ $(which htop) ] && xterm -e htop||xterm -e top 
}

# menu
rclick_menu()
{
[ $(which htop) ] && export label=Htop||export label=Top
export rclick="
<window decorated=\"false\">
 <vbox>
  <hbox>
  <text><label>About</label></text>
   <button>
    <input file stock=\"gtk-about\"></input>
    <action>EXIT:about</action> 
   </button>
  </hbox>
  <hbox>
  <text><label>${label}</label></text>
   <button>
    <input file stock=\"gtk-info\"></input>
    <action>EXIT:htop</action> 
   </button>
  </hbox>
  <hbox>
  <text><label>Pprocess</label></text>
   <button>
    <input file stock=\"gtk-preferences\"></input>
    <action>EXIT:pp</action> 
   </button>
  </hbox>
  <hbox>
  <text><label>Quit</label></text>
   <button>
    <input file stock=\"gtk-quit\"></input>
    <action>EXIT:quit</action> 
   </button>
  </hbox>
 </vbox>
</window>"
eval $(gtkdialog --class="nolist" -p rclick --geometry +$XDIM+$YDIM)
case $EXIT in
about)Xdialog -title "CPU Tray" -msgbox "Cpu Tray - 0.1\n\nCredits: \
\ntechnosaurus - sit C code\nPaul Colby - cpu code\n01micko - bash code" 0 0 ;;
htop)lclick ;;
pp)pprocess & ;;
quit)kill -9 $(pidof sit)
killall $PROG;;
esac
}

# make icon
cpu2svg() #again ftom techno
{
i=$1
FFAMILY=helvetica
ARCH=$(uname -m)
[ "${ARCH##??}" != "86" ] && FFAMILY=dejavu-sans

T=16
[ "$i" = "100" ] && T=12
BG="#FF00FF" #hot pink (default)
	[ "$i" -le "10" ] && BG='#D7FFFF' #pale blue
	[[ "$i" -gt "10" && "$i" -le "25" ]] && BG="#00FFFF" #light blue
	[[ "$i" -gt "25" && "$i" -le "50" ]] && BG="#FFD7D7" #pale pink
echo '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  <rect width="34"
     height="22"
     x="0"
     y="0"
     rx="3"
     ry="3"
     style="font-size:'${T}';fill:'$BG';fill-opacity:0.75;fill-rule:evenodd;stroke-width:3pt;"
     id="rect1" />
  <text
     x="0"
     y="18"
     style="font-size:'${T}';font-weight:normal;fill-opacity:0.75;stroke-width:3pt;font-family:'$FFAMILY';"
     id="text1">
    <tspan
       id="tspan1">'"${i}%"'</tspan>
  </text>
</svg>'	> /tmp/cpuicon/cpu.svg
}

# calculate cpu usage
cpuusage() #Paul Colby http://colby.id.au/node/39
{
PREV_TOTAL=0
PREV_IDLE=0
 
while true; do
  CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics.
  unset CPU[0]                          # Discard the "cpu" prefix.
  IDLE=${CPU[4]}                        # Get the idle CPU time.
 
  # Calculate the total CPU time.
  TOTAL=0
  for VALUE in "${CPU[@]}"; do
    let "TOTAL=$TOTAL+$VALUE"
  done
 
  # Calculate the CPU usage since we last checked.
  let "DIFF_IDLE=$IDLE-$PREV_IDLE"
  let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL"
  let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10"
  #echo -en "\rCPU: $DIFF_USAGE%  \b\b" # uncomment for commandline output
  cpu2svg $DIFF_USAGE
 
  # Remember the total and idle CPU times for the next check.
  PREV_TOTAL="$TOTAL"
  PREV_IDLE="$IDLE"
 
  # Wait before checking again.
  sleep 1
done
}
cpuusage &

mainfunc()
{
sit 1000 /tmp/cpuicon/cpu.svg "cpu usage" "lclick" "rclick_menu" 2>/dev/null | \
while read LINE; do
case "$LINE" in
 *)$LINE &
 ;; 
esac
done
}
#main
mainfunc
It's still buggy though as I can't sort out the right pid to kill for sit.
Puppy Linux Blog - contact me for access

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#58 Post by technosaurus »

Code: Select all

sit ... &
SITPID=$!


kill $SITPID
btw you shouldn't need the while read... now that it can execute stuff directly. but you made me wonder if I should check if file exists before refreshing and die if it is missing.

If builds are failing it is probably because some of the explicit dependencies were not linked to the one or more libraries. If the shared libraries have all of their direct dependencies linked (all of and only those which they directly use symbols from) then the dynamic linker can figure all of that out... otherwise you get build nightmares. Often the problem is that something is broken in an upper level library is unknowingly broken and goes unseen because there is a symbol of the same name in another library that gets explicitly linked. as a general rule of thumb, if you only have the gtk/gtk.h header, you should only link the gtk library. Otherwise a best case is that you are missing a .so symlink and are linking in a static library (due to having -glib -lcairo -pango ...) which makes the binary larger and prevents bugs from getting fixed with a shared library update and since gtk depends on the shared version, the shared version shows up as a dependency. a worse case is when an #ifdef HAVE_SOMETHING tells the compiler to build a replacement something and you then get conflicting names. I would only link the tertiary dependencies if a -static flag were passed - autotools, pkgconfig libtool et.al have a broken understanding of how linux works - probably because they are still trying to support systems that no-one uses.

... so please let me know the error so I can help fix the problem before more broken packages get built. ... on the other hand, I probably should directly link to gio for the file watch stuff (perhaps it is possible to build gtk without depending on it at all?) - try just adding that since I _did_ add those (the previous inotify build is better suited to linux builds, but not portable because it uses a low overhead linux system call with almost no latency vs. an 800ms refresh and gobject overhead - I just started my masters in cs, so I am trying to pay more attention to portability so my stuff works for classmates)
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#59 Post by 01micko »

Here's the failure on the Pi, Sap6

Code: Select all

# ./build
cc1: error: unrecognized command line option "-mno-accumulate-outgoing-args"
..and I removed, march and mtune options as I don't know what to put there on this arch (tried armel, armv61)

Hers's the slacko error

Code: Select all

# ./build
/usr/lib/gcc/i486-slackware-linux/4.7.1/../../../../i486-slackware-linux/bin/ld: /tmp/ccgrle57.o: undefined reference to symbol 'g_signal_connect_data'
/usr/lib/gcc/i486-slackware-linux/4.7.1/../../../../i486-slackware-linux/bin/ld: note: 'g_signal_connect_data' is defined in DSO /usr/lib/libgobject-2.0.so.0 so try adding it to the linker command line
/usr/lib/libgobject-2.0.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
Note that's using -current binaries as of August so bugs may be fixed upstream, (or not). I'm pretty sure gtk has been rebuilt and glib since then. I don't plan on woofing another beta until 14.0 goes live, anytime soon I guess.

----------------------------------------------------------------------------------------------

EDIT1 (raspberry pi)

Code: Select all

"-march=armv5te -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=softfp"
maybe :?:

EDIT2: seems to be working with -march=armv5te -mtune=arm1176jzf-s .. taking ages! (3 secs on the fast box)

EDIT3: -march=armv5te -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=softfp works too, bin is 4 bytes bigger then previous. The orig with no options was 5488B, second was 4632B, third was 4636B.

EDIT4 (this is in slackware-current, just ran slackpkg --update-all)

Code: Select all

bash-4.2# ./build
/usr/lib/gcc/i486-slackware-linux/4.7.1/../../../../i486-slackware-linux/bin/ld: /tmp/ccZFd30d.o: undefined reference to symbol 'g_signal_connect_data'
/usr/lib/gcc/i486-slackware-linux/4.7.1/../../../../i486-slackware-linux/bin/ld: note: 'g_signal_connect_data' is defined in DSO /usr/lib/libgobject-2.0.so.0 so try adding it to the linker command line
/usr/lib/libgobject-2.0.so.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
Looks pretty much the same as my slacko errors.
Puppy Linux Blog - contact me for access

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#60 Post by technosaurus »

Ok, I think I understand now. Most distros build gtk with gio features enabled, but it is possible to have a minimal enough config, that it doesn't link gio. I'd bet Abiword had non-functioning menu items too, since it expects the gvfs portion of it.... It won't hurt anything to add it. Damn ARM, I already cut the unwind stuff, perhaps a separate build?

On a separate note, I was thinking about adding changeable tooltips by reading a file and updating when the file is modified (just like the icons)... Any thoughts?
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
boscobearbank
Posts: 63
Joined: Thu 06 Apr 2006, 15:13
Location: MN

#61 Post by boscobearbank »

Technosaurus: The code below may not be pretty, but it does what I need it to do, thanks to sit-1.0. Thanks.

Code: Select all

#!/usr/bin/python

""" A very, very simple front-end for ffmpeg to capture screencasts
    Capture area begins in upper-left corner of screen
    Size of capture area is user-definable
    Frame rate is fixed at 25 fps
    Output resolution = input resolution
    No audio
    Output file is user-specified (except for container type
    Container type = Matroska
    Cludged together by RockDoctor
    Version 1  23-Sep-2012
"""

from gi.repository import Gtk
import os, signal, sys, subprocess

process = 'ffmpeg'
kill_sig = signal.SIGINT
mycmd = ''

# ======================================================================
def process_killer():

  l_process = len(process)
  for line in os.popen('ps ax'):
    fields = line.split()
    if fields[4][0:l_process]==process:
      pid_of_process = int(fields[0])
      print (pid_of_process)
      os.kill(pid_of_process, kill_sig)

# ======================================================================
class SitApp:
  """
  an adaptation and butchering of technosaurus's sit.c
  adapted by RockDoctor
  """

  def __init__(self):
    si = Gtk.StatusIcon.new_from_stock("gtk-stop")
    si.set_tooltip_text("Click to stop recording")
    si.connect("activate",self.leftClick,process_killer)
    si.connect("popup-menu",self.rightClick,process_killer)
    Gtk.main()

  def leftClick(self, status_icon, action):
    #print ("Interrupting ",process)
    action()
    #print ("Left-click")
    sys.exit()


  def rightClick(self, status_icon, button, mytime, action):
    #print ("Interrupting "+str(process)+"  button="+str(button)+"  time="+str(mytime)+"\n")
    action()
    #print ("Right-click")
    sys.exit()

# ======================================================================
class ScreenRecorder:
  """ A very simple screencast recorder
      Original command:
      ffmpeg -f x11grab -s 840x525 -r 25 -i :0.0 -threads 0 -sameq -an  /home/a/Desktop/video.mkv 2>/dev/null
  """
  def __init__(self):

    self.i_params = {}
    self.o_params = {}
    self.i_params['f'] = 'x11grab' # input from X11 screen
    self.i_params['s'] = '802x514' # input frame size
    self.i_params['r'] = '25'    # input file frame rate
    self.i_params['i'] = ':0.0'  # input file (or stream)

    self.o_params['threads'] = '0'
    self.o_params['sameq'] = ''  # same quality in encoder as in decoder
    self.o_params['an'] = ''     # disable audio recording

    self.outfile_name =  '/home/a/Desktop/video'
    self.outfile_extension = '.mkv'

    # I'm only going to permit modification of a limited number of the
    # above parameters (which are a very limited number of the
    # parameters available to ffmpeg for screen recording)

    w = Gtk.Window(title = "Screen Capture via FFMPEG")
    w.connect('destroy', Gtk.main_quit)
    w.set_default_size(400,300)
    vbox = Gtk.VBox(spacing=15)

    grid = Gtk.Grid()
    grid.set_row_spacing(3)
    grid.set_column_spacing(3)

    btn = Gtk.Button()
    btn.set_label("Frame Size: ")
    btn.set_alignment(0,0.5)
    btn.set_relief(Gtk.ReliefStyle.NONE)
    grid.attach(btn,0,0,1,1)
    s_entry = Gtk.Entry()
    s_entry.set_text(self.i_params['s'])
    grid.attach(s_entry,1,0,1,1)

    btn = Gtk.Button()
    btn.set_label("Output filename (w/o extension):")
    btn.set_alignment(0,0.5)
    btn.set_relief(Gtk.ReliefStyle.NONE)
    grid.attach(btn,0,1,1,1)
    f_entry = Gtk.Entry()
    f_entry.set_text(self.outfile_name)
    grid.attach(f_entry,1,1,1,1)

    btn = Gtk.Button(stock='gtk-execute')
    btn.connect('clicked', self.start_ffmpeg)
    grid.attach(btn,0,2,2,1)

    vbox.pack_start(grid, False, False, 0)
    w.add(vbox)
    self.w = w
    self.w.show_all()

    Gtk.main()

  def start_ffmpeg(self, widget):
    my_cmd = 'ffmpeg -f x11grab -s '+self.i_params['s']+' -r 25 -i :0.0 -threads 0 -sameq -an  '+self.outfile_name+'.mkv'
    self.w.hide()
    command = my_cmd.split()
    try:
      subprocess.Popen(['rm',self.outfile_name+'.mkv'])
    except:
      pass
    subprocess.Popen(command)
    Gtk.main_quit()

# ======================================================================
def main(data=None):
    app2 = ScreenRecorder()
    app1 = SitApp()

if __name__ == '__main__':
    main()


Bosco Bearbank

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#62 Post by technosaurus »

I just updated some stuff and broke the old api:

startup will fail verbosely if an image does not stat
replaced popen with g_spawn_command_line_async (now you can get streamed output from your left/right click action helpers)
this also means it should now be 100% portable to non-posix systems
added tooltips from file, falls back to the argument if file does not stat
tooltips will automatically update if the file changes
no tooltip is set if "" is passed
no callbacks are issued for right/leftclick if the command is "" (NULL)
  • usage:
    sit image [tooltip_file] [left_action] [right_action] ... \
    image ["tooltip text"] [left_action] [right_action] ... \
    ... this may be repeated for an unlimited number of icons

Code: Select all

#include <gtk/gtk.h>

void leftclick(GtkStatusIcon *si, gpointer s){
	g_spawn_command_line_async(s,NULL);
}

void rightclick(GtkStatusIcon *si, guint b,guint a_t, gpointer s){
	g_spawn_command_line_async(s,NULL);
}

/** refreshes the status icon image from file if it changes */
void refresh(GFileMonitor *monitor, GFile *file, GFile *to_file, GFileMonitorEvent event, gpointer si){
   gtk_status_icon_set_from_file(si,g_file_get_path(file));
}

/** gets a new mouse over tooltip from file if it changes */
void updatetooltip(GFileMonitor *monitor,   GFile *file, GFile *to_file, GFileMonitorEvent event, gpointer si){
   gtk_status_icon_set_tooltip_text(si, g_mapped_file_get_contents(g_mapped_file_new(g_file_get_path(file), FALSE, NULL)));
}

int main(int argc, char *argv[]){
	GtkStatusIcon *si;
	char i=1;
gtk_init (&argc, &argv);
if ( argc < 2 ) {
	g_printerr("usage:\n%s /path/to/image /path/to/tooltip left-action right-action ...\n",argv[0]);
	return 1;
}
/** loop through icon, tooltip, click messages **/
while (i<argc){
/** status icon **/
if (g_file_test(argv[i], G_FILE_TEST_EXISTS)){
	si = gtk_status_icon_new_from_file(argv[i]);
	g_signal_connect(g_file_monitor_file(g_file_new_for_path(argv[i++]), G_FILE_MONITOR_NONE, FALSE, NULL),
		"changed", G_CALLBACK(refresh),(gpointer) si);
}else{
	g_printerr("error: could not stat file %s\n",argv[i]);
	return 2;
}
/** tooltip **/
if (g_file_test(argv[i], G_FILE_TEST_EXISTS)){
   gtk_status_icon_set_tooltip_text(si, g_mapped_file_get_contents(g_mapped_file_new(argv[i], FALSE, NULL)));
   g_signal_connect(g_file_monitor_file(g_file_new_for_path(argv[i++]), G_FILE_MONITOR_NONE, FALSE, NULL),
      "changed", G_CALLBACK(updatetooltip),(gpointer) si);
}else{
	if (argv[i]!=NULL) gtk_status_icon_set_tooltip_text(si, argv[i]);
	++i;
}
/** left click action **/
if (argv[i]!=NULL) g_signal_connect(G_OBJECT(si), "activate", G_CALLBACK(leftclick),(gpointer) argv[i]);
++i;
/** right click action **/
if (argv[i]!=NULL) g_signal_connect(G_OBJECT(si), "popup-menu", G_CALLBACK(rightclick), (gpointer) argv[i]);
++i;
}
gtk_main();
}
Attachments
sit.tar.gz
(1.99 KiB) Downloaded 632 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

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

#63 Post by seaside »

technosaurus,

Some nice updates here.

I especially liked the tooltips from a file idea, but I couldn't get that to work (perhaps I'm invoking the line wrong

Code: Select all

 sit /usr/share/pixmaps/group-chat.png /root/tooltip_file

Also tried the filename with double quotes.

Thanks and regards,
s
(Also got a "seg fault" and no useage info if just "sit" on command line)

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#64 Post by technosaurus »

the file needs to exist when sit starts (it checks if it exists,so that the file monitor works), otherwise your tooltip will be that arg value "/root/tooltip_file" which will be unchangeable (which is perfectly normal for most situations) - it basically just lets you do things like update the network statistics as in the network monitor applet

Edit: I still need to update the original post, use my last binary from this post:
http://www.murga-linux.com/puppy/viewto ... 170#654170
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

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

#65 Post by seaside »

technosaurus,

I forgot I had the older copy of sit in the path when I tried it.

All works well as described. Great work as usual.

Thanks,
S

Post Reply