Ubuntu: How can I prevent people to see what application(s) I have opened?



Question:

I don't want people to see what applications I have opened. I would like to be able to instantly hide the windows with a shortcut key combination, so I can save my work afterwards. I also want to hide their presence in the Launcher.

I tried to duckduckgo it but did not find any solution.


Solution:1

IMPORTANT EDIT

With the commands:

xdotool windowunmap <window_id>  

and

xdotool windowmap <window_id>  

it turns out there is a way to completely mask the presence of application windows temporarily. Even the wmctrl -l command will not list the windows any more.

I will post the new answer below and leave the first answer as a second option.


New answer:

Hiding windows and the applications they belong to

With the script below, you can completely hide (unmap) application windows from your desktop. Their presence will not be visible at all, since their Launcher icons will not show an arrow as well.

How to use:

  • The script needs both wmctrl and xdotool to get the window properties, the pid they belong to and to manage the windows of selected applications:

    sudo apt-get install wmctrl  sudo apt-get install xdotool  
  • Copy the script below into an empty file

  • In the head section of the script, list the applications you'd like to (be able to) quickly hide the windows of. Use the format:

    applications = ["firefox", "gedit"]  
  • Save it as hide_windows.py

  • Make the script run from a shortut key: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:

    python3 /path/to/hide_windows.py  
  • Now if you press the key combination once, the windows of defined applications will be completely hidden, their launcher icon will not show the application runs.

  • Press again and all windows will appear again.

The script:

#!/usr/bin/env python3  import subprocess  import getpass  import os    #---  applications = ["chrome", "firefox", "gedit"]  #---    windowlist = os.environ["HOME"]+"/"+".windowlist.txt"  user = getpass.getuser()    get = lambda x: subprocess.check_output(["/bin/bash", "-c", x]).decode("utf-8")  wlist = [l for l in get("wmctrl -lp").splitlines()]  procs = sum([[p.split()[0] for p in get("ps -u "+user).splitlines() if app in p] for app in applications], [])  matches = sum([[l.split()[0] for l in wlist if p in l] for p in procs], [])    if len(matches) != 0:      with open(windowlist, "wt") as out:          for match in matches:              out.write(match+"\n")              subprocess.Popen(["/bin/bash", "-c", "xdotool windowunmap "+match])  else:      try:          with open(windowlist) as r:              for l in r.readlines():                  subprocess.Popen(["/bin/bash", "-c", "xdotool windowmap "+l])          os.remove(windowlist)      except FileNotFoundError:          pass  

How it works

When called, the script lists all windows from the applications, set in the head of the script. Subsequently, it does two things:

  • It writes the window id of the windows to a hidden file (to be able to remap the windows, since they even disappear from the output of wmctrl -l)

    enter image description here

  • It unmaps the windows

  • When called again, the script will not find any windows to unmap, it will read the file with window ids and restore the windows.

    enter image description here




First answer:

(Perfectly working, but another approach and a bit more work)

Hiding opened applications from the Launcher?

I doubt if it is possible to completely erase all traces of an application in Unity and the Launcher. At least not by means of simple modifications, since the Launcher is designed to show a representation of GUI applications.

If your goal is however to prevent people to see what applications you have currently open, that can be done by simple modifications.

A combination of two things that can easily be done

The solution I would suggest exists of two measures:

  1. A misleading represenation of the application in the launcher

    My altered representation of Firefox in the launcher:

    <image1>

    You can simply change both the appearing name and the icon to anything you like.

  2. A key shortcut to instantly hide the windows of defined application(s).

    This can be a large number of windows, they will be all minimized in one action (key combination)

Combined, these two measures should do what you want: prevent people to recognize what applications you are running.

How to set up

1. A misleading represenation of the application in the launcher

(I'll use the example of Firefox)

Changing the appearing name:

  • Applications are represented by .desktop files in /usr/share/applications or ~/.local/share/applications.
    We need to edit a local copy of the firefox.desktop file, so first copy it:

    cp /usr/share/applications/firefox.desktop ~/.local/share/applications/firefox.desktop  
  • Open the file in gedit (drag the file over an opened gedit window or run:

    gedit ~/.local/share/applications/firefox.desktop  
  • Now we are going to change the name of Firefox, as it appears in the Launcher:
    Right below the first two lines, you will see an impressive list of localized names. Look for the language tag, corresponding to the language of your system. I am Dutch, so I have to change the name in the line:

    Name[nl]=Firefox webbrowser  

    and I change it into:

    Name[nl]=Monkey eats banana  

    Changing the appearing icon:

  • While the .desktop file is still open, Look for the line:

    Icon=firefox  

    Replace it by:

    Icon=/path/to/icon.png  

    (If you replace it by your own custom icon, you will probably need to use the absolute path to the icon.)

    After you log out/in, Firefox will appear as "Monkey eats banana" in both the Launcher and Dash, but you will still find it as firefox as well:

    enter image description here

2. A key shortcut combination to hide the windows of defined application(s)

  • The script needs both wmctrl and xdotool to get the window properties, the pid they belong to and to manage the windows of selected applications:

    sudo apt-get install wmctrl  sudo apt-get install xdotool  
  • Copy the script below into an empty file

  • In the head section of the script, list the applications you'd like to (be able to) quickly hide the windows of. Use the format:

    applications = ["firefox", "gedit"]  
  • Save it is hide_windows.py

  • Make the script run from a shortut key: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:

    python3 /path/to/hide_windows.py  

    Now test it by running your applications and press the key combination. The windows of the defined applications will minimize, their launcher icon is a riddle.

    The script

    #!/usr/bin/env python3  import subprocess  import getpass    #---  applications = ["firefox", "gedit"]  #---    get = lambda x: subprocess.check_output(["/bin/bash", "-c", x]).decode("utf-8")  wlist = [l for l in get("wmctrl -lp").splitlines()]  user = getpass.getuser()  procs = sum([[p.split()[0] for p in get("ps -u "+user).splitlines() if app in p] for app in applications], [])  for match in sum([[l.split()[0] for l in wlist if p in l] for p in procs], []):      subprocess.Popen(["/bin/bash", "-c", "xdotool windowminimize "+match])  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »