title: How to clear both clipboards securely in Gnome, from Python?
body: <p>Gnome desktop has 2 clipboards, the X.org (saves every selection) and the legacy one (CTRL+C). I am writing a simple python script to clear both clipboards, securely preferably, since it may be done after copy-pasting a password.</p>
  
  <p>The code that I have seen over here is this:</p>
  
  <pre><code># empty X.org clipboard
  os.system("xclip -i /dev/null")  
  
  # empty GNOME clipboard
  os.system("touch blank")  
  os.system("xclip -selection clipboard blank")  
  </code></pre>
  
  <p>Unfortunately this code creates a file named <code>blank</code> for some reason, so we have to remove it:</p>
  
  <pre><code>os.remove("blank")
  </code></pre>
  
  <p>However the main problem is that by calling both of these scripts, it leaves the <code>xclip</code> process open, even after I close the terminal.</p>
  
  <h2>So we have 2 problems with this option:</h2>
  
  <h2>1) It creates a blank file, which seems like a flawed method to me</h2>
  
  <h2>2) It leaves a process open, which could be a security hole.</h2>
  
  <p>I also know about this method:</p>
  
  <pre><code> os.system("echo "" | xclip -selection clipboard")  # empty clipboard
  </code></pre>
  
  <p>However this one leaves a <code>\n</code> newline character in the clipboard, so I would not call this method effective either.</p>
  
  <p>So how to do it properly then?</p>