I noticed that Vovchik's Yweather application uses markup in the icon tooltip.
Is it possible for "sit" to do this as well?
![Question :?:](./images/smilies/icon_question.gif)
Regards,
s
jamesbond,jamesbond wrote:Patch:
1. Remove default include files path (if this path doesn't exist, execution fails - bad)
2. change popen mode from "r" to "w" - otherwise no output
3. ensure pclose after popen so that we don't get zombie process
4. close pid from g_spawn_async
5 add version numbering so we know which version of sit this is.
6. modify build process so that it is 64-bit compatible (should still work on 32-bit)
7. modify build process so that it tests correctly
Code: Select all
./build
/usr/bin/ld: /tmp/cckw5xNo.o: undefined reference to symbol 'g_file_monitor_file'
/usr/bin/ld: note: 'g_file_monitor_file' is defined in DSO /usr/lib/libgio-2.0.so.0 so try adding it to the linker command line
/usr/lib/libgio-2.0.so.0: could not read symbols: Invalid operation
collect2: ld returned 1 exit status
Code: Select all
sit.c -o sit -lgtk-x11-2.0 && strip --strip-all -R .note -R .comment sit
Code: Select all
sit.c -o sit -lgtk-x11-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 && strip --strip-all -R .note -R .comment sit
Code: Select all
sit.c -o sit $(pkg-config --libs gtk+-2.0) && strip --strip-all -R .note -R .comment sit
jamesbond,jamesbond wrote:
Change line 7 in "build" fromToCode: Select all
sit.c -o sit -lgtk-x11-2.0 && strip --strip-all -R .note -R .comment sit
Note the addition of -lgio-2.0 -lgobject-2.0 -lglib-2.0.Code: Select all
sit.c -o sit -lgtk-x11-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 && strip --strip-all -R .note -R .comment sit
Code: Select all
-i <include files>
-b <background imagge>
-t <status icon> <tooltip> <left click action> <right click action>
the -t option can be used multiple times,
Code: Select all
<pixmap tooltip-text="'$(gettext ' This is a good idea! ')'">
<input file>'$WORKDIR'/icons/lightbulb.png</input>
</pixmap>
Code: Select all
# Makefile for sdesk.
#CC = /usr/i386-linux-uclibc/bin/i386-uclibc-gcc
#CC = diet gcc
#CC = musl-gcc
CC ?= gcc
#CFLAGS = -pipe -Os -mtune=i386 -static -s -Wall -I/usr/i386-linux-uclibc/usr/include
#CFLAGS = -pipe -Os -mtune=i386 -static -s -Wall
CFLAGS = -Os -finline-small-functions -ffunction-sections -fdata-sections -fmerge-all-constants \
-fomit-frame-pointer -mno-accumulate-outgoing-args -fno-unwind-tables -fno-asynchronous-unwind-tables
#LDFLAGS = -L/usr/i386-linux-uclibc/lib -lm -Wl,--gc-sections,--sort-common,-s
LDFLAGS = -Wl,--gc-sections,--sort-common,--as-needed,-s -lm `pkg-config gtk+-x11-2.0 --libs`
#see stb_vorbis for various size vs. speed defines
DEFINES = `pkg-config gtk+-x11-2.0 --cflags`
OBJECTS = sdesk.c
BINDIR = /usr/bin
sdesk: $(OBJECTS)
$(CC) $(CFLAGS) $(DEFINES) $(OBJECTS) $(LDFLAGS) -o sdesk
install:
strip --strip-all -R .note -R .comment sdesk
install sdesk $(BINDIR)/sdesk
uninstall:
rm -f $(BINDIR)/sdesk
clean:
rm -f *.o sdesk
depend:
gccmakedep -- $(CFLAGS) -- sdesk.c
Code: Select all
#include <stdio.h>
#include <fcntl.h>
void do_bat0(char *svg,char *tt){
char var[64],val[64],model[32]="",oem[32]="",battype[32]="",text[]="Battery";
int dcap=0,cap=0,rcap=1,dv=0,pv=0,warn=0,low=0,present='n',sz=48,percent;
FILE *state = fopen("/proc/acpi/battery/BAT0/state", "r"),
*info = fopen("/proc/acpi/battery/BAT0/info", "r"),
*svgfp = fopen(svg, "w"),
*ttfp = fopen(tt, "w");
while (fscanf(info, "%64[^:] %*s %64[^\n]\n", var, val) != EOF){
if (!strcmp("design capacity",var)) sscanf(val, "%d %*s", &dcap);
if (!strcmp("last full capacity",var)) sscanf(val, "%d %*s", &cap);
if (!strcmp("design voltage",var)) sscanf(val, "%d %*s", &dv);
if (!strcmp("model number",var)) sscanf(val, " %s", &model);
if (!strcmp("OEM info",var)) sscanf(val, " %s", &oem);
if (!strcmp("battery type",var)) sscanf(val, " %s", &battype);
if (!strcmp("design capacity warning",var)) sscanf(val, "%d %*s", &warn);
if (!strcmp("design capacity low",var)) sscanf(val, "%d %*s", &low);
}
fclose(info);
while (fscanf(state, "%64[^:] %*s %64[^\n]\n", var, val) != EOF){
if (!strcmp("present",var)) sscanf(val, "%c%*s", &present);
if (!strcmp("remaining capacity",var)) sscanf(val, "%d %*s", &rcap);
if (!strcmp("present voltage",var)) sscanf(val, "%d %*s", &pv);
}
fclose(state);
percent=(100*cap)/rcap;
fprintf(svgfp, "<svg width=\"%dpx\" height=\"%dpx\" version=\"1.1\" " \
"viewBox=\"0 0 200 200\" preserveAspectRatio=\"none\" " \
"xmlns=\"http://www.w3.org/2000/svg\">\n" \
"<rect x=\"20%%\" width=\"60%%\" height=\"100%%\" fill=\"#111\"/>\n" \
"<rect x=\"20%%\" width=\"60%%\" y=\"%d%%\" height=\"%d%%\" fill=\"#0F0\"/>\n" \
"<text x=\"100\" y=\"100\" fill=\"#FFF\" font-size=\"%d\" " \
"text-anchor=\"middle\" transform=\"rotate(90 100,100)\">%s</text>\n" \
"</svg>", sz, sz, 100-percent, percent, 200/(strlen(text)-1), text);
fclose(svgfp);
fprintf(ttfp, "%20s: %s\n" "%20s: %s\n" "%20s: %s\n" "%20s: %d mWh\n",
"Make", oem, "Model", model, "Type", battype, "Percent remaining", percent );
fclose(ttfp);
}
int main(int argc, char **argv){
do_bat0("batt.svg","batt.tt");
return 0;
}
#if 0 //another example for /proc file with a header
int main(int argc, char **argv){
FILE *fp = fopen("/proc/net/arp", "r");
char ip[99], hw[99], flags[99], mac[99], mask[99], dev[99], dummy[99];
fgets(dummy, 99, fp);
while (fscanf(fp, "%s %s %s %s %s %s\n", ip, hw, flags, mac, mask, dev) != EOF)
if (!strcmp(argv[1],ip))
printf("%s\n",dev);
return 0;
}
#endif