WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Add your own buttons to wbar  (Read 9663 times)

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Add your own buttons to wbar
« on: May 28, 2009, 11:23:37 AM »
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: [Select]
# 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 &

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: [Select]
#!/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

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.
« Last Edit: June 01, 2009, 12:05:36 PM by bigpcman »
big pc man

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: Add your own buttons to wbar
« Reply #1 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
« Last Edit: May 28, 2009, 09:59:11 PM by jpeters »

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: Add your own buttons to wbar
« Reply #2 on: May 29, 2009, 09:59:25 AM »
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
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
« Last Edit: June 01, 2009, 12:12:11 PM by bigpcman »
big pc man

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: Add your own buttons to wbar
« Reply #3 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.
10+ Years Contributing to Linux Open Source Projects.

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: Add your own buttons to wbar
« Reply #4 on: May 29, 2009, 11:00:41 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.

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.
big pc man

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: Add your own buttons to wbar
« Reply #5 on: May 29, 2009, 11:03:52 AM »
If you insist on not using supported methods, then don't post them, as it only adds to the complexity of support the system. It becomes a scatter mode of which we are trying to avoid.
10+ Years Contributing to Linux Open Source Projects.

Offline bigpcman

  • Hero Member
  • *****
  • Posts: 719
Re: Add your own buttons to wbar
« Reply #6 on: May 29, 2009, 11:11:34 AM »
If you insist on not using supported methods, then don't post them, as it only adds to the complexity of support the system. It becomes a scatter mode of which we are trying to avoid.

OK, I get your point. So then let me make sure I understand the correct method. The correct method would be to create a tce/tcz that contains the script (even if it is just one line), the tce.wbar entries file and the default icon.

edit: Actuallly, now that I have thought about it for awhile I am already loading a custom tce that has other files in it so it is not a big deal to add the tce.wbar entries file and icon to it. The script is already in my sdc1 storage area and is called from the tce.wbar entry so it doesn't need to be in the tce.

edit2: See post http://forum.tinycorelinux.net/index.php?topic=1729.0 for the rest of the information required to add wbar buttons.
« Last Edit: June 01, 2009, 11:22:19 AM by bigpcman »
big pc man