How to Display "Save Icon" on the System Taskbar?

Moderator: Forum moderators

Post Reply
sonny
Posts: 618
Joined: Mon Feb 15, 2021 4:50 pm
Has thanked: 449 times
Been thanked: 142 times

How to Display "Save Icon" on the System Taskbar?

Post by sonny »

Hello all,
How do I display the Save icon (for Pupmode=13) on the taskbar in the clock section like featured in Fossapup?
Very much appreciated!

TerryH
Posts: 580
Joined: Mon Jun 15, 2020 2:08 am
Has thanked: 115 times
Been thanked: 133 times

Re: How to Display "Save Icon" on the System Taskbar

Post by TerryH »

In Fossapup ther is a script in /root/Startup named pm13trayicon, that is what puts the icon in the tray. The script runs pm13, which is contained in /usr/sbin. Other newer puppys use this method also.

The code in pm13trayicon is:

Code: Select all

#!/bin/ash

exec pm13 trayicon "$@"

New Laptop - ASUS ZenBook Ryzen 7 5800H Vega 7 iGPU / 16 GB RAM

sonny
Posts: 618
Joined: Mon Feb 15, 2021 4:50 pm
Has thanked: 449 times
Been thanked: 142 times

Re: How to Display "Save Icon" on the System Taskbar

Post by sonny »

Thank you, TerryH.
I will try if it is also applicable in Bionicpup.

sonny
Posts: 618
Joined: Mon Feb 15, 2021 4:50 pm
Has thanked: 449 times
Been thanked: 142 times

Re: How to Display "Save Icon" on the System Taskbar

Post by sonny »

Copying the "pm13" file into /usr/sbin folder and copying the "pm13trayicon" file into /Startup manages to display the Save icon on the tray. However, clicking on the icon will not display the "Save RAM to pupsave NOW" button.
So, it is not applicable in Bionicpup.

sonny
Posts: 618
Joined: Mon Feb 15, 2021 4:50 pm
Has thanked: 449 times
Been thanked: 142 times

Re: How to Display "Save Icon" on the System Taskbar

Post by sonny »

Is the any way to display an icon on the system tray (in the clock section on the bottom right), not on the bottom left alongside the menu button?
Thank you again!

User avatar
rockedge
Site Admin
Posts: 5864
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2104 times
Been thanked: 2199 times
Contact:

Re: How to Display "Save Icon" on the System Taskbar

Post by rockedge »

If your interested in coding right side tray icon here is an example:
This is written in C and will need to be compiled. Load the devx sfs for your system to include the tools.
This example I added curl commands to send X10 commands to a USB transceiver to turn a light on and off remotely.

Screenshot(52).png
Screenshot(52).png (26.46 KiB) Viewed 1092 times

Code: Select all

/* demo_tray.c

	gcc -o demo_tray demo_tray.c -w `pkg-config --libs gtk+-3.0` `pkg-config --cflags gtk+-3.0` 
	gcc -o demo_tray demo_tray.c -w `pkg-config --libs gtk+-2.0` `pkg-config --cflags gtk+-2.0`
	
  	A tray icon demo app for linux to monitor the existence of a file.
  	Green means yes, red means no.
  	
  	To test from a separate console window:
  	root# touch /tmp/traydemo.txt
	root# rm /tmp/traydemo.txt
 
  	- jafadmin - November 2020
*/
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <glib/gstdio.h>
#include <curl/curl.h>

////// 	Images resources
#include "green-check-orig.xpm"
#include "red-cross-orig.xpm"
GdkPixbuf *green_check_pixbuf;
GdkPixbuf *red_cross_pixbuf;
////// 	End images ...

#define FILE_EXISTS	0
#define CONTINUE	1

char test_file_name[]="/tmp/switch_on.txt";

GtkStatusIcon *tray_icon;
unsigned int interval = 3000; /* Update interval in milliseconds ( 1 second = 1000 milliseconds) */

gboolean ChkStatus(gpointer ptr) // State switcher. This does all the work ..
{
	if(access(test_file_name, F_OK) == FILE_EXISTS)  // Does file exist?
	{
		gtk_status_icon_set_from_pixbuf(tray_icon, green_check_pixbuf); 	
		gtk_status_icon_set_tooltip_text(tray_icon, "File is there");
	}		
	else
	{ 								
		gtk_status_icon_set_from_pixbuf(tray_icon, red_cross_pixbuf); 	
		gtk_status_icon_set_tooltip_text(tray_icon, "File is missing");	
	}	
    return CONTINUE;        			
}

////// The following two functions handle left & right clicks on the tray icon
void tray_icon_on_left_click(GtkStatusIcon *status_icon,  gpointer user_data) 
{
	char DeleteCmd[80];	// Make a shell command to delete the testfile
	
	strcpy(DeleteCmd, "rm ");	
	strcat(DeleteCmd, test_file_name);
    system(DeleteCmd); 
  CURL *curl;
  CURLcode res;
    curl = curl_easy_init();
    curl_easy_setopt(curl, CURLOPT_URL, 
    "http://192.168.0.5:8008/?house=B&unit=9&command=OFF");
    curl_easy_perform(curl);
       		
}

void tray_icon_on_right_click(GtkStatusIcon *status_icon, guint button,  guint activate_time, gpointer user_data)
{
	char TouchCmd[80];	// Recreate the file using 'touch'
	
	strcpy(TouchCmd, "touch ");	
	strcat(TouchCmd, test_file_name); 
    system(TouchCmd);    
  CURL *curl;
  CURLcode res;
    curl = curl_easy_init();
    curl_easy_setopt(curl, CURLOPT_URL, 
    "http://192.168.0.5:8008/?house=B&unit=9&command=ON");
    curl_easy_perform(curl);
    	
	// Or .. you could just have it:
    // gtk_main_quit();
}
////// End clicks  ...

static GtkStatusIcon *create_tray_icon() 
{
    GtkStatusIcon *tray_icon;
    tray_icon = gtk_status_icon_new();
    
    green_check_pixbuf=gdk_pixbuf_new_from_xpm_data((const char**)green_check_pixbuf);
    red_cross_pixbuf=gdk_pixbuf_new_from_xpm_data((const char**)red_cross_pixbuf);

	// Connect handler functions to signals from X
    g_signal_connect(G_OBJECT(tray_icon), "activate", G_CALLBACK(tray_icon_on_left_click), NULL);
    g_signal_connect(G_OBJECT(tray_icon), "popup-menu", G_CALLBACK(tray_icon_on_right_click), NULL);
    
    gtk_status_icon_set_tooltip_text(tray_icon,  "X10_tray app");
    gtk_status_icon_set_visible(tray_icon, TRUE);
    
    return tray_icon;
}

int main(int argc, char **argv) 
{		
	gtk_init(&argc, &argv);        
    tray_icon = create_tray_icon();        
    g_timeout_add(interval, ChkStatus, NULL);	// Call our worker function, ChkStatus()
    gtk_main();
    return 0;
}
x10_tray.tar.gz
(20.72 KiB) Downloaded 42 times
TerryH
Posts: 580
Joined: Mon Jun 15, 2020 2:08 am
Has thanked: 115 times
Been thanked: 133 times

Re: How to Display "Save Icon" on the System Taskbar

Post by TerryH »

sonny wrote: Sun Feb 21, 2021 9:35 pm

Copying the "pm13" file into /usr/sbin folder and copying the "pm13trayicon" file into /Startup manages to display the Save icon on the tray. However, clicking on the icon will not display the "Save RAM to pupsave NOW" button.
So, it is not applicable in Bionicpup.

I just copied the pm13 and created the startup script, made it executable. Then restarted X. It is the Tray and executable. Unfortunately the version of Puppy Event Manager, in BionicPup32 is an older version, it doesn't include "Save RAM to pupsave NOW" button, which is in the newer releases.

To make the script executable.

chmod +x /root/Startup/pm13trayicon OR right-click the file and select properties, then click the Exec Check boxes

New Laptop - ASUS ZenBook Ryzen 7 5800H Vega 7 iGPU / 16 GB RAM

sonny
Posts: 618
Joined: Mon Feb 15, 2021 4:50 pm
Has thanked: 449 times
Been thanked: 142 times

Re: How to Display "Save Icon" on the System Taskbar

Post by sonny »

Thank you for your notes, rockedge and TerryH!

User avatar
nilsonmorales
Posts: 126
Joined: Thu Dec 26, 2019 1:47 am
Location: El Salvador
Has thanked: 53 times
Been thanked: 75 times
Contact:

Re: How to Display "Save Icon" on the System Taskbar?

Post by nilsonmorales »

Code: Select all

file /usr/bin/pm13tray
/usr/bin/pm13tray: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=133127dd094c3820ecbfd993336357e4f0487647, for GNU/Linux 3.2.0, stripped

anyone know where is the source code for this. tnx

User avatar
mikeslr
Posts: 2851
Joined: Mon Jul 13, 2020 11:08 pm
Has thanked: 173 times
Been thanked: 862 times

Re: How to Display "Save Icon" on the System Taskbar?

Post by mikeslr »

The code which actually performs the "Save" is save2flash. But the following will create a lauNot sure how to get a launcher on the right-hand side of the Task-bar.. You need create or reference a Save Icon. You'll find lots in /usr/local/lib/X11/themes; for example /usr/local/lib/X11/themes/Aromat_coffe/save48.png.

1. Using your text editor create a desktop file named Save2flash with the following arguments:
[Desktop Entry]
Encoding=UTF-8
Name=Save2Flash
Icon= /usr/local/lib/X11/themes/Aromat_coffe/save48.png >Example
Comment=performs a Save
Exec=save2flash
Terminal=false
Type=Application
Categories=Archiving
NoDisplay=false > colored for emphasis only

2. Place the desktop file in /usr/share/applications.
3. Run Menu>Exit>Restart-x, AKA Graphical Server

You can now place a launcher to Save2Flash on the Taskbar as you would any other application.
The application will also appear on Menu>Utilities. If you don't want that AFTER creating the Taskbar launcher edit the desktop file so that NoDisplay=true

The icon will NOT change when you change themes.

Post Reply

Return to “Bionic”