Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions i3session
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3

import os
import i3
Expand Down Expand Up @@ -90,7 +90,7 @@ class Tree():
elif n['window']:
# get process from xprop
node = Node(n)
n[u'process'] = node.get_wm_class()
n['process'] = node.get_wm_class()

return nodes

Expand Down Expand Up @@ -133,7 +133,7 @@ def nag_bar_process():

# print usage instructions
def show_help():
print(sys.argv[0] + " <save|restore> [workspace]")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This set of parens seems redundant?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I don't know why 2to3 added them.

print((sys.argv[0] + " <save|restore> [workspace]"))

if __name__ == '__main__':
# logging.basicConfig(level=logging.DEBUG)
Expand All @@ -152,24 +152,24 @@ if __name__ == '__main__':
sys.exit(1)

if sys.argv[1] == 'save':
print "Saving..."
print("Saving...")
session = i3.get_tree()

# traverse tree and assign node processes before storing
if session['nodes']:
session['nodes'] = Tree.assign_processes(session['nodes'])

pickle.dump(session, open(config_file, "wb"))
print "Session saved to " + config_file
print("Session saved to " + config_file)
elif sys.argv[1] == 'restore':
nag_bar = nag_bar_process()
print "Restoring..."
print("Restoring...")

# load session from file
try:
session = pickle.load(open(config_file, "rb"))
except Exception:
print "Can't restore saved session..."
print("Can't restore saved session...")
sys.exit(1)

# traverse tree and send commands to i3 based on what was saved
Expand All @@ -180,7 +180,7 @@ if __name__ == '__main__':
Tree.restore(session['nodes'])

nag_bar.terminate()
print "Session restored from " + config_file
print("Session restored from " + config_file)
else:
show_help()
sys.exit(1)