Advertisement
Guest User

workspace_change

a guest
Feb 10th, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2.  
  3. import argparse
  4. import sys
  5.  
  6. from xpybutil import conn, root
  7. import xpybutil.ewmh as ewmh
  8.  
  9. parser = argparse.ArgumentParser(
  10.     description='Change workspace name',
  11.     formatter_class=argparse.ArgumentDefaultsHelpFormatter)
  12. aa = parser.add_argument
  13. aa('change_from', type=str, metavar='EXISTING_NAME',
  14.    help='The name of the workspace to change.')
  15. aa('change_to', type=str, metavar='NEW_NAME',
  16.    help='The NEW name of the workspace.')
  17.  
  18. conf = parser.parse_args()
  19.  
  20. names = ewmh.get_desktop_names(conn, root).reply()
  21.  
  22. # Which name do we want to change?
  23. for i, name in enumerate(names):
  24.     if name == conf.change_from:
  25.         names[i] = conf.change_to
  26.         ewmh.set_desktop_names_checked(conn, root, names).check()
  27.         print 'Changed %s to %s' % (conf.change_from, conf.change_to)
  28.         break
  29. else:
  30.     print >> sys.stderr, 'Could not find workspace named %s' % conf.change_from
  31.     sys.exit(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement