unity - How to make a show desktop icon in a corner of the screen? - Ask Ubuntu
i know how put show desktop icon in launcher, i'd have 1 in corner.
the reason in launcher have "carefully" click on it, while if it's on corner, can more "aggressive".
edit: i've tested of solutions in answers none accomplishes objective, maybe because didn't accurately: want, in corner,a show desktop icon(or not, don't care if instead have move pointer corner ) such when select it, desktop shown , can work in desktop, example copy file there, open terminal,etc. , then, can go back windows minimized same icon.
@serg 's solution has 2 issues: 1) icon fixed, it's not in corner. 2) doesn't let me go windows minimized.
@heynnema 's solution has major issue icon "shows" desktop, can't work on it: if right-click on empty space open terminal, space might not "empty" in sense if had open window there, right click options displayed 1 of window before being minimize.
@gautamvashisht 's solution seems same heynnema, cause hot corners activated whenever activate in ccsm.
disclaimer: author of indicator , written specific question
introduction
ubuntu default doesn't have option move "show desktop" icon - has live on launcher. can have show in alt+tab menu. however, possible create small indicator applet, live in top panel, comes pretty close requirement of placing icon corner of screen. answer provides that
usage
usage simple. save code in ~/bin
folder, example me /home/serg/bin/show_desktop_indicator
. in order make open every time log ubuntu, search in dash "startup applications", open app, , add full path indicator new command.
you can download zip folder indicator project's github page
essentially, minimizes open windows. there's 2 ways go it. one, can click on indicator icon, , click "show desktop" menu entry, or use middle-mouse click on icon itself.
code
also available on github
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # author: serg kolo , contact: 1047481448@qq.com # date: november 5th, 2016 # purpose: appindicator minimizing windows # written for: http://askubuntu.com/q/846067/295286 # tested on: ubuntu 16.04 lts # # # licensed under mit license (mit). # see included license file or notice below. # # copyright © 2016 sergiy kolodyazhnyy # # permission hereby granted, free of charge, person obtaining copy # of software , associated documentation files (the "software"), deal # in software without restriction, including without limitation rights # use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of software, , permit persons whom software # furnished so, subject following conditions: # # above copyright notice , permission notice shall included # in copies or substantial portions of software. # # software provided "as is", without warranty of kind, express or # implied, including not limited warranties of merchantability, # fitness particular purpose , noninfringement. in no event shall # authors or copyright holders liable claim, damages or other # liability, whether in action of contract, tort or otherwise, arising from, # out of or in connection software or use or other dealings in # software. import gi gi.require_version('appindicator3', '0.1') gi.require_version('notify', '0.7') gi.repository import glib glib gi.repository import appindicator3 appindicator gi.repository import gtk gtk gi.repository import gdk class showdesktop(object): def __init__(self): self.app = appindicator.indicator.new( 'files-indicator', "user-desktop", appindicator.indicatorcategory.other ) self.app.set_status(appindicator.indicatorstatus.active) self.make_menu() def add_menu_item(self, menu_obj, item_type, image, label, action, args): """ dynamic function can add menu items depending on item type , other arguments""" menu_item, icon = none, none if item_type gtk.imagemenuitem , label: menu_item = gtk.imagemenuitem.new_with_label(label) menu_item.set_always_show_image(true) if '/' in image: icon = gtk.image.new_from_file(image) else: icon = gtk.image.new_from_icon_name(image, 48) menu_item.set_image(icon) elif item_type gtk.imagemenuitem , not label: menu_item = gtk.imagemenuitem() menu_item.set_always_show_image(true) if '/' in image: icon = gtk.image.new_from_file(image) else: icon = gtk.image.new_from_icon_name(image, 16) menu_item.set_image(icon) elif item_type gtk.menuitem: menu_item = gtk.menuitem(label) elif item_type gtk.separatormenuitem: menu_item = gtk.separatormenuitem() if action: menu_item.connect('activate', action, *args) menu_obj.append(menu_item) menu_item.show() def make_menu(self): self.app_menu = gtk.menu() content = [self.app_menu,gtk.menuitem, none,'show desktop', self.show_desktop,[none] ] self.add_menu_item(*content) last = none in self.app_menu.get_children(): last = self.app.set_secondary_activate_target(last) content = [self.app_menu,gtk.imagemenuitem, 'exit','quit', self.quit,[none] ] self.add_menu_item(*content) self.app.set_menu(self.app_menu) def show_desktop(self,*args): screen = gdk.screen.get_default() w in screen.get_window_stack(): w.iconify() w.process_all_updates() def run(self): """ launches indicator """ try: gtk.main() except keyboardinterrupt: pass def quit(self, *args): """ closes indicator """ gtk.main_quit() def main(): """ defines program entry point """ indicator = showdesktop() indicator.run() if __name__ == '__main__': try: main() except keyboardinterrupt: gtk.main_quit()
indicator in action:
ubuntu kylin icon theme:
Comments
Post a Comment