Distraction free writing is all the rage these days, and I’m a huge proponent of the movement because I am very prone to distraction. Why right now, I should be doing something else, but I got distracted with this!
Anyway, one of my essential tools for a distraction free environment is a totally black desktop with no icons showing. Each operating system has techniques for making this happen, but I have found a solution that works on all operating systems equally. The only requirement is that you have Python installed (tested on 2.7).
This code runs as an app, so you don’t have to change any operating system settings to get it to work, and as soon as you want to see your desktop again, just double-right-click on the black background and it will exit!
Here’s the python code to make it happen (watch out for word wrapping).
#!/usr/bin/python
from Tkinter import *
class App():
def __init__(self):
self.root = Tk()
self.root.overrideredirect(1)
screen_width = self.root.winfo_screenwidth()
screen_height = self.root.winfo_screenheight()
self.frame = Frame(self.root, width=screen_width, height=screen_height,
borderwidth=0, relief=RAISED, background="#000000")
self.frame.bind("<FocusIn>", self.unfocus)
self.frame.bind("<Button-1>", self.unfocus)
self.frame.bind("<Double-Button-1>", self.unfocus)
self.frame.bind("<Double-Button-2>", self.quit)
self.frame.pack_propagate(False)
self.frame.pack()
self.root.geometry('%dx%d+%d+%d' % (screen_width, screen_height, 0, 0))
self.root.lower();
# self.root.call('wm', 'attributes', '.', '-topmost', True)
# self.root.after_idle(self.root.call, 'wm', 'attributes', '.', '-topmost', False)
def quit(self, event):
self.root.quit()
def unfocus(self, event):
self.root.lower()
app = App()
app.root.mainloop()
Leave a Reply