multiple desktops



Hello,

I wrote a simple python scripts which changes Desktop
folder when current workspace is changed. The script
basically simlinks the Desktop folder to different
folders. However, each time to make the changes
visible i have to reload Desktop by hitting Ctrl+R. Is
there any way to invoke this from within a python
script, i.e., via dbus?

Thanks


      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping
#! /usr/bin/env python
"""
*  Copyright (C) 2008  Sergei Krivov <krivov yahoo com>
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""
"""
Separate desktop for each workspace:
Hit Ctrl-R to refresh desktop, each time when switched to new workspace.
If someone knows, how to force Nautilus to reload the page, please let me know.
Desktops are changing by simliking the ~\Desktop directory to ~/.desktops/Desktop0,
~/.desktops/Desktop1, etc. If no corresponding ~/.desktops/Desktopx is present,
Desktop0 is used. To add new desktop for particular workspace create the directory
.desktops/Desktopxx, where xx is the number of the workspace.
"""

import gtk,wnck,os

# define event-handlers
def active_workspace_changed(screen):
    ws=screen.get_active_workspace().get_number()
    print "Workspace changed",ws 
    desktop='%s/Desktop%s' %(desktops,ws)
    if os.access(desktop,os.F_OK):# desktop exists
        os.popen('rm %s/Desktop' %home)
        os.popen('ln -s %s %s/Desktop' %(desktop,home))
    else:
        os.popen('rm %s/Desktop' %home)
        os.popen('ln -s %s/Desktop0 %s/Desktop' %(desktops,home))
        
home=os.path.expanduser('~')
desktops=home+'/.desktops'

if not os.access(desktops,os.F_OK):
  print """No ~/.desktops directory is present.
The ~/.desktops directory will be created; you current Desktop will be moved
there as ~/.desktops/Desktop0 and soft-linked back 
ln -s ~/.desktops/Desktop0 ~/Desktop """
  com=raw_input("Enter yes to continue\n")
  if com=='yes' or com=='y':
    os.popen('mkdir '+desktops)
    os.popen('mv %s/Desktop %s/Desktops0' %(home,desktops))
    os.popen('ln -s %s/Desktop0 %s/Desktop' %(desktops,home))

screen=wnck.screen_get_default()
screen.connect("active_workspace_changed",active_workspace_changed)

gtk.main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]