Tiny Core Extensions > TCE Tips & Tricks

Add your own buttons to wbar

(1/2) > >>

bigpcman:
Here's how I did it. I just added my information to /usr/share/wbar/dot.wbar. There are three entries per button:
i: = image
t: = text
c: = command
Then make dot.wbar persistent using the backup system or by creating a custom tce extension containing all changed system files.
Note the png is 48x48 pixels at 72 dpi.


--- Code: ---# The Bar && Font && Font size (11)
i: /usr/share/wbar/osxbarback.png
t: /usr/share/fonts/luxisr/11
c:
i: /usr/share/wbar/aterm.png
t: Aterm
c: exec /usr/bin/aterm
i: /usr/share/wbar/cpanel.png
t: Panel
c: exec /usr/bin/cpanel
i: /usr/share/wbar/appbrowser.png
t: Apps
c: exec /usr/bin/appbrowser
i: /mnt/sdc1/mywbar/samba-wbar-active.png
t: S
c: exec /mnt/sdc1/mywbar/samba-wbar &

--- End code ---

My button toggles between two colors to show the state of the program that gets activated by displaying two different images. The script below (samba-wbar) uses three images on, off and active to support the toggle function.


--- Code: ---#!/bin/sh
#bigpcman May 28, 2009

 start(){
  /mnt/sdc1/samba/samba_server start 2>&1 > /dev/null &
  sleep 4
  sudo cp -f /mnt/sdc1/mywbar/samba-wbar-on.png /mnt/sdc1/mywbar/samba-wbar-active.png 2>&1 > /dev/null &
  /usr/bin/wbar.sh 2>&1 > /dev/null &
 }

 stop(){
  /mnt/sdc1/samba/samba_server stop 2>&1 > /dev/null &
  sleep 4
  sudo cp -f /mnt/sdc1/mywbar/samba-wbar-off.png /mnt/sdc1/mywbar/samba-wbar-active.png 2>&1 > /dev/null &
  /usr/bin/wbar.sh 2>&1 > /dev/null &
 }

 PID=$(pidof smbd)
 [ -n "$PID" ] && stop || start

--- End code ---

edit: Note the "active image" should be  initialized by a custom tce or by a cp command in the bootlocal script to make sure it is in the correct state after a bootup.

jpeters:
I think that (just the samba portion) goes into /usr/local/tce-icons as a separate file that will load/unload  with your samba extension

bigpcman:

--- Quote from: jpeters on May 28, 2009, 09:47:25 PM ---I think that (just the samba portion) goes into /usr/local/tce-icons as a separate file that will load/unload  with your samba extension

--- End quote ---
That's an interesting point, tcz.uninstall samba3 would not remove the icon from the wbar unless it was in /usr/local/tce-icons. I wonder how the tcz-uninstall tool would know which icon to remove since I put it there "manually" as opposed to the smaba3.tcz installer. Perhaps it would need a "special name? Actually the tcz.uninstall tool would have to know to remove the entire dot.wbar entry. How would it know to do that? My preference would be to add a wbar removal function to my samba manager script.

edit: I don't know what I was thinking here, I went way off track with my answer. I never want my "button" to load or unload with samba since it is responsible for managing samba (install/uninstall and start/stop)! This button is a system level button for me and should always be present.  :-X

roberts:
You should avoid modifying the system file and use the already supported /usr/local/tce.icons area. Perhaps you should request that your mods be included in the samba extension rather than adding to an already complex situation.

bigpcman:

--- Quote from: roberts on May 29, 2009, 10:47:27 AM ---You should avoid modifying the system file and use the already supported /usr/local/tce.icons area. Perhaps you should request that your mods be included in the samba extension rather than adding to an already complex situation.

--- End quote ---

For custom wbar buttons in general, buttons that just run a script, if I put them in tce.wbar "manually" how do I make them persistent. I have tried a few things and it looks like I would have to make a "dummy" tce to get my entries into tce.wbar. Putting my entries in dot.wbar removes this complexity.

Navigation

[0] Message Index

[#] Next page

Go to full version