Hi,
i wonder if it is possible to have a Bash/GtkDialog Application sitting in the Task Bar as small icon -at the right side, just like the firewall icon- instead of having a big button at the Task Bar?
No, not like "show icons only" in the FbPanel Settings.
Is this possible?
What would i have to do?
RSH
GtkDialog/Bash Application in System Task Bar
GtkDialog/Bash Application in System Task Bar
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]
Thank you veery much, vovchik.vovchik wrote:Dear RSH,
I don't think thunor has done the tray icon bit yet for gtkdialog - but you can use gtrayicon 1.1 for this purpose and have it run a gtkdialog script.
With kind regards,
vovchik
I did find gtrayicon already installed in LazY Puppy. Unfortunately the --help and --help-all command gives me nothing what I could understand to be able to run a script from gtrayicon.
Do you have any example code or similar?
RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]
RSH
Here's a different approach
I named this file example.c
It will run anything in $PATH named example.sh. You can also add a right click menu (look at my tempicon_source for a rough example in utilities section)
Be careful with C! A little knowledge of it is dangerous! (like I am )
You also could try techno's SIT
There are also examples in genie language in the genie/vala thread, but they are a bit old now and will give compile warnings.
Here's a different approach
Code: Select all
#include <gtk/gtk.h>
#include <gdk/gdk.h>
/* gcc -o example example.c `pkg-config --libs --cflags gtk+-2.0` (to compile)*/
GdkPixbuf *a_pixbuf;
GError *gerror = NULL;
GtkStatusIcon *tray_icon;
void tray_icon_on_click(GtkStatusIcon *status_icon,
gpointer user_data)
{
printf("Clicked on tray icon\n"); //you can comment this
system("example.sh");
}
static GtkStatusIcon *create_tray_icon()
{
//GtkStatusIcon *tray_icon;
tray_icon = gtk_status_icon_new();
g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_click), NULL);
a_pixbuf=gdk_pixbuf_new_from_file("/usr/local/lib/X11/pixmaps/utility24.png",&gerror);
gtk_status_icon_set_from_pixbuf(tray_icon,a_pixbuf);
gtk_status_icon_set_tooltip(tray_icon, "Start Utility Example");
gtk_status_icon_set_visible(tray_icon, TRUE);
return tray_icon;
}
int main(int argc, char **argv) {
GtkStatusIcon *tray_icon;
gtk_init(&argc, &argv);
tray_icon = create_tray_icon();
gtk_main();
return 0;
}
It will run anything in $PATH named example.sh. You can also add a right click menu (look at my tempicon_source for a rough example in utilities section)
Be careful with C! A little knowledge of it is dangerous! (like I am )
You also could try techno's SIT
There are also examples in genie language in the genie/vala thread, but they are a bit old now and will give compile warnings.
- Attachments
-
- example.png
- (43.9 KiB) Downloaded 999 times
Puppy Linux Blog - contact me for access
RSH,
You might find technosaurus' SIT program useful here-
http://murga-linux.com/puppy/viewtopic.php?t=76431
It places an icon in the tray and allows you lots of options for running programs.
Cheers,
s
(SIT=Simple Icon Tray)
You might find technosaurus' SIT program useful here-
http://murga-linux.com/puppy/viewtopic.php?t=76431
It places an icon in the tray and allows you lots of options for running programs.
Cheers,
s
(SIT=Simple Icon Tray)
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
it will now do as many icons as will fit in your tray along with left and right mouse click actions, but most importantly it automatically refreshes the image when it is changed (gtkdialog and gtrayicon do not - though I posted a hacky patch for gtkdialog) The most recent version is cross platform too and still in <20 lines compiling to <3kb. Zigbert's ptray is a good alternative too if you are using jwm (I have started integrating that function into jwm tools too)seaside wrote:RSH,
You might find technosaurus' SIT program useful here-
http://murga-linux.com/puppy/viewtopic.php?t=76431
It places an icon in the tray and allows you lots of options for running programs.
Cheers,
s
(SIT=Simple Icon Tray)
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].
Hi everyone.
Thanks for all the replies and useful tips and suggestions.
I will use this one, because it makes me totally independent in creating system tray applications - for the rest of my life.
Thanks a lot for this C example - it surely will be used in several applications to come.
RSH
Thanks for all the replies and useful tips and suggestions.
I will use this one, because it makes me totally independent in creating system tray applications - for the rest of my life.
My knowledge on C is surely less than nothing. But -as you might know- if one has good/rich knowledge on at least one programming language makes it easier to read different code - especially if something like clear (human language) text is inside the code. I have good/rich knowledge of PASCAL (which is a lot different to C) and -by now- nearly good based knowledge on bash and so, i could read the code, could modify it for my purposes and was able to compile it.01micko wrote:RSH
Here's a different approachI named this file example.cCode: Select all
#include <gtk/gtk.h> #include <gdk/gdk.h> /* gcc -o example example.c `pkg-config --libs --cflags gtk+-2.0` (to compile)*/ GdkPixbuf *a_pixbuf; GError *gerror = NULL; GtkStatusIcon *tray_icon; void tray_icon_on_click(GtkStatusIcon *status_icon, gpointer user_data) { printf("Clicked on tray icon\n"); //you can comment this system("example.sh"); } static GtkStatusIcon *create_tray_icon() { //GtkStatusIcon *tray_icon; tray_icon = gtk_status_icon_new(); g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_click), NULL); a_pixbuf=gdk_pixbuf_new_from_file("/usr/local/lib/X11/pixmaps/utility24.png",&gerror); gtk_status_icon_set_from_pixbuf(tray_icon,a_pixbuf); gtk_status_icon_set_tooltip(tray_icon, "Start Utility Example"); gtk_status_icon_set_visible(tray_icon, TRUE); return tray_icon; } int main(int argc, char **argv) { GtkStatusIcon *tray_icon; gtk_init(&argc, &argv); tray_icon = create_tray_icon(); gtk_main(); return 0; }
It will run anything in $PATH named example.sh. You can also add a right click menu (look at my tempicon_source for a rough example in utilities section)
Be careful with C! A little knowledge of it is dangerous! (like I am )
You also could try techno's SIT
There are also examples in genie language in the genie/vala thread, but they are a bit old now and will give compile warnings.
Thanks a lot for this C example - it surely will be used in several applications to come.
RSH
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]
Oh, that's wonderful.
I was able to add a right-click menu to the above C Code and also to add some new functions, that runs several applications. Also i do check inside this functions if the application is available. If not, it runs the RunScript for the use of the SFS.
That's pretty cool, since this was my first real "hack" ever on C Code.
@ 01micko
The tempicon application has been very helpful on that. I assume it will be alright, if i post my "hacked" Code here? I think it could be interesting to others and maybe someone will find a bug on this...
I have also written a script to compile this C Code. If you click the script it wants to compile example.c inside the script's directory. But you can drag & drop a C Code file from any else directory onto this script and it compiles the dropped file. So you can rename this or the above example.c and compile it using a new name for it.
This script is only for the use on the above posted C Code files!
I was able to add a right-click menu to the above C Code and also to add some new functions, that runs several applications. Also i do check inside this functions if the application is available. If not, it runs the RunScript for the use of the SFS.
That's pretty cool, since this was my first real "hack" ever on C Code.
@ 01micko
The tempicon application has been very helpful on that. I assume it will be alright, if i post my "hacked" Code here? I think it could be interesting to others and maybe someone will find a bug on this...
Code: Select all
//#############################################################################
// System Tray Application Starter
// Original C Code by 01micko
// Modified by RSH for the use of the LazY DNS - (D)ow(N)load (S)uite
// LazY DNS Wrapper 0.3
//#############################################################################
// to compile: gcc -o example example.c `pkg-config --libs --cflags gtk+-2.0`
//#############################################################################
// Include Files
#include <gtk/gtk.h>
#include <gdk/gdk.h>
// Icons
GdkPixbuf *a_pixbuf;
GtkStatusIcon *tray_icon;
// Error Check on File Open
GError *gerror = NULL;
// File and Filenames
FILE *fp;
char lazyfredname[37]="/usr/local/LazY-FReD/set_preferences";
char lazyreconame[30]="/usr/local/LazY-FReD/LazYReCo";
char lazymaidname[30]="/usr/local/LazY-MAID/LazYMAID";
//#############################################################################
// Right-Click Functions called from Menu
//#############################################################################
// Run LazY FReD
static run_lazy_fred(){
fp = fopen(lazyfredname,"r");
if(fp == NULL)
{
system("/root/.my-sfs-scripts/LP2_LazY-FReD-1.0.3.sfs.Scripts/LP2_LazY-FReD-1.0.3.sfs.LazY-FReD.run.sh &");
return 1;
}
system("/usr/local/LazY-FReD/set_preferences &");
}
// Run LazY ReCo
static run_lazy_reco(){
fp = fopen(lazyreconame,"r");
if(fp == NULL)
{
system("/root/.my-sfs-scripts/LP2_LazY-FReD-1.0.3.sfs.Scripts/LP2_LazY-FReD-1.0.3.sfs.LazY-ReCo.run.sh &");
return 1;
}
system("/usr/local/LazY-FReD/LazYReCo &");
}
// Run LazY MAID
static run_lazy_maid(){
fp = fopen(lazymaidname,"r");
if(fp == NULL)
{
system("/root/.my-sfs-scripts/LP2_LazY-MAID-1.0.2.sfs.Scripts/LP2_LazY-MAID-1.0.2.sfs.LazY-MAID.run.sh &");
return 1;
}
system("/usr/local/LazY-MAID/LazYMAID &");
}
//#############################################################################
// Left-Click Function on System Tray Icon
//#############################################################################
// Run LazY DNS if left-clicked on icon
static tray_icon_on_click(GtkStatusIcon *status_icon,
gpointer user_data)
{
system("/usr/local/LazY-DNS/LazYDNS");
}
//#############################################################################
// Right-Click-Menu Functions
//#############################################################################
// Menu Entry LazY DNS
void view_popup_menu_run_lazy_dns (GtkWidget *menuitem, gpointer user_data)
{
system("/usr/local/LazY-DNS/LazYDNS &");
}
// Menu Entry LazY FReD
void view_popup_menu_run_lazy_fred (GtkWidget *menuitem, gpointer user_data)
{
run_lazy_fred();
}
// Menu Entry LazY ReCo
void view_popup_menu_run_lazy_reco (GtkWidget *menuitem, gpointer user_data)
{
run_lazy_reco();
}
// Menu Entry LazY MAID
void view_popup_menu_run_lazy_maid (GtkWidget *menuitem, gpointer user_data)
{
run_lazy_maid();
}
// Menu Entry Quit
void view_popup_menu_quit (GtkWidget *menuitem, gpointer user_data)
{
gtk_main_quit();
}
// nothing
static view_popup_menu_dummy (GtkWidget *menuitem, gpointer user_data)
{
return 2;
}
//#############################################################################
// Menu Function
//#############################################################################
// Right-Click on System Tray Icon
void tray_icon_on_menu(GtkStatusIcon *status_icon, guint button, guint activate_time, gpointer user_data)
{
GtkWidget *menu, *menuitem;
menu = gtk_menu_new();
menuitem = gtk_menu_item_new_with_label("LazY DNS 0.3 Download Suite");
g_signal_connect(menuitem, "activate", (GCallback) view_popup_menu_run_lazy_dns, status_icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new();
//g_signal_connect(menuitem, "none", (GCallback) view_popup_menu_dummy, status_icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new_with_label("LazY FReD Free Repository Downloader");
g_signal_connect(menuitem, "activate", (GCallback) view_popup_menu_run_lazy_fred, status_icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new_with_label("LazY ReCo Repository Collector");
g_signal_connect(menuitem, "activate", (GCallback) view_popup_menu_run_lazy_reco, status_icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new_with_label("LazY MAID Murga-Linux Attachment-Index Downloader");
g_signal_connect(menuitem, "activate", (GCallback) view_popup_menu_run_lazy_maid, status_icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new();
//g_signal_connect(menuitem, "none", (GCallback) view_popup_menu_dummy, status_icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
menuitem = gtk_menu_item_new_with_label("LazY DNS 0.3 Beenden");
g_signal_connect(menuitem, "activate", (GCallback) view_popup_menu_quit, status_icon);
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, button, gdk_event_get_time(NULL));
}
//#############################################################################
// System Tray Icon
//#############################################################################
// Create Tray Icon
static GtkStatusIcon *create_tray_icon()
{
tray_icon = gtk_status_icon_new();
g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_click), NULL);
g_signal_connect(G_OBJECT(tray_icon), "popup-menu", G_CALLBACK(tray_icon_on_menu), NULL);
a_pixbuf=gdk_pixbuf_new_from_file("/usr/local/LazY-DNS/icons/lazydns24.png",&gerror);
gtk_status_icon_set_from_pixbuf(tray_icon,a_pixbuf);
gtk_status_icon_set_tooltip(tray_icon, "LazY DNS 0.3 Download Suite");
gtk_status_icon_set_visible(tray_icon, TRUE);
return tray_icon;
}
//#############################################################################
// Main Program Functions
//#############################################################################
// Main Program
int main(int argc, char **argv)
{
gtk_init(&argc, &argv);
create_tray_icon();
gtk_main();
return 0;
}
//#############################################################################
// End of LazY DNS Wrapper
//#############################################################################
This script is only for the use on the above posted C Code files!
Code: Select all
#!/bin/sh
FindExec="gcc"
file_to_compile="$1"
f_t_c="`basename $file_to_compile`"
d_t_c="`dirname $file_to_compile`"
nlen="`echo ${#f_t_c}`"
o_f=${f_t_c:0:$nlen-2}
Titel="Compiling $f_t_c"
if [ "$(which $FindExec)" ]; then
echo "C Compiler already loaded"
else
Xdialog --title "$Titel" --wrap --screen-center --center --ok-label "Load" --cancel-label "Do ot load" --yesno "\nC Compiler missing. \n\nUYou have to load the devx.sfs of your puppy." 0 0
exit 1
#if [ "$?" = "0" ]; then
# sfs_load --cli --quiet Your_DevX_Here.sfs
#fi
fi
if [ "$(which $FindExec)" ]; then
if [ "$file_to_compile" = "" ]; then
# compile example.c
lxterminal -e gcc -o example example.c `pkg-config --libs --cflags gtk+-2.0`
else
# compile file dropped on the script
cd $d_t_c
lxterminal -e gcc -o "$o_f" "$f_t_c" `pkg-config --libs --cflags gtk+-2.0`
fi
fi
exit 0
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]