Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #!/usr/local/env/ python
  2. # -*- coding:utf-8 -*-
  3.  
  4. import os, pystray
  5. from pystray import MenuItem as item, Menu as menu
  6. from PIL import Image
  7.  
  8. def action(menuitem=None):
  9. os.system("notify-send 'action is pressed'")
  10. pass
  11.  
  12. def dummy(menuitem=None):
  13. if menuitem:
  14. os.system("echo got it: " + str(menuitem))
  15. os.system("notify-send 'iniciando SSH para: "+menuitem+"'")
  16. os.system("xfce4-terminal -e 'aruba'") ## esto funciona porque tengo creados alias para aruba, de lo contrario habría que indicar el comando ssh completo
  17. pass
  18.  
  19. image = Image.open("icon.png")
  20.  
  21. # fijate, un item para tener el label, y dentro el menu sin mas
  22. aruba = item('Submenu 1', menu(item('SSH aruba', lambda : dummy('aruba'))))
  23. siruelo = item('Submenu 2', menu(item('SSH siruelo', lambda : dummy('siruelo'))))
  24.  
  25. menu = (aruba, siruelo)
  26.  
  27. icon = pystray.Icon("name", image, "title", menu=menu)
  28. icon.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement