Ubuntu: A file not visible on desktop if one screen is vertically oriented?



Question:

I have 2 screen where one is normal horizontal, and the other one is vertical.

After I changed that files that I download to desktop are no longer visible. I can see them in Nautilus->Desktop, but not by bare eye. I guess Ubuntu puts those files in the virtual area below BenQ monitor and leftOf the vertical monitor.

Any ideas how to solve this?

Note: Files on my desktop are manually sorted and Keep Aligned is ticked off!

This is not the duplicate of How to configure GNOME 3 to show icons on desktop as this does not deal with desktop icons like Trash, My Network, etc. The actual file is not visible on BENQ screen. I also installed this app, but it neither helps nor has the feature mentioned in that post. I guess the post is too old and the app had changed as of then.


Solution:1

What happens

Your assumption that the downloaded files "landed" in the "blind" area is correct: You can get the icons position with the command:

gvfs-info <item>  

This outputs the coordinates 64,1382 (x/y), which makes clear the icon is positioned below the left screen (1382 > 1080).

This is most likely the result of a bug.

The script below can be used to move newly created files on the virtual (spanning) desktop from one area (e.g. the invisible section) to another location (in this case: the visible section).

Properties of the script

Although the script seems extended, it is written in such a way that unnecessary actions and routines are avoided. If no new items appear on the desktop, it only checks for new files, causing a processor load of practically none.

What it does

  • Once per second, the script checks for new items in the desktop folder
  • If new item(s) are found, it checks the location, moves them into the visible area if necessary

enter image description here

However, the desktop needs to be refreshed after the items are moved, which can only be done if the desktop is the frontmost "folder". The script therefore sets refresh to True. On the first occasion the desktop is in front, the script:

  • refreshes the desktop.

How to use

The script needs both xdotool and wmctrl to be installed:

sudo apt-get install xdotool  sudo apt-get install wmctrl  

xautomation should already be on your system, but in case it is not:

sudo apt-get install xautomation  

Then:

  • Copy the script below into an empty file, save it as blind_area.py
  • In the head section of the script, set the size of your left screen:

    left_scr = [1920, 1080]  
  • Set the localized name for your desktop folder (probably just "Desktop", but in Dutch it would be "Bureaublad" for example)

  • Set the resolution of the left screen if it is different from what I set
  • Test-run the script by the command:

    python3 /path/to/blind_area.py  
  • I test-ran it by setting the vertical size of my screen to half its actual size, which moved all new(!) icons to the top 50% of my screen.

  • Note that the move actions will be visible once you clicked the desktop (or have the desktop in front in any way).
  • If all works fine, add it to your startup applications: Dash > Startup Applications > Add the command:

    /bin/bash -c "sleep 15&&python3 /path/to/blind_area.py"  

The script

#!/usr/bin/env python3  import subprocess  import os  import time    #--- set localized name of the Desktop folder below  desktop_name = "Desktop"  #--- set the resolution of the left screen below  left_scr = [1920, 1080]  #---    get = lambda cmd: subprocess.check_output(["/bin/bash", "-c", cmd]).decode("utf-8")  home = os.environ["HOME"]  dr = home+"/"+desktop_name  # used strings  val = " 'metadata::nautilus-icon-position' "  search = "gvfs-info -a"+val  set_val = "gvfs-set-attribute -t string "  refresh_cmd = "xte 'key F5'"  # function to check if desktop is in front  def check_frontmost():      try:          frontmost = str(hex(int(get("xdotool getwindowfocus").strip())))          frontmost = frontmost[:2]+"0"+frontmost[2:]          w_list = [l.split() for l in get("wmctrl -lG").splitlines()]      except subprocess.CalledProcessError:          return False      else:          check = len([l for l in w_list if all([str(space[0]) in l, frontmost in l, str(space[1]) in l])]) > 0          return check  # function to get the resolution  def get_res():      xr = get("xrandr").split(); pos = xr.index("current")      return [int(xr[pos+1]), int(xr[pos+3].replace(",", "") )]    dtfiles_1 = []  refresh = False    while True:      # check current files      time.sleep(1)      dtfiles_2 = os.listdir(dr)      # check for new files, move if necessary      newfiles = [f for f in dtfiles_2 if all([          not f in dtfiles_1,          not f.endswith("~"),          not f.startswith("."),          ])]      if len(newfiles) != 0:          # check desktop size (only if new files appear)          space = get_res()      for f in newfiles:          fdir = os.path.join(dr, f);  fdir = "'"+fdir+"'" if fdir.count(" ") != 0 else fdir          try:              loc = [int(n) for n in eval(get(search+fdir).split()[-1:][0])]          except:              pass          else:              if all([loc[0] < left_scr[0], loc[1] > left_scr[1]]):                  command = set_val+fdir+" "+val+str(loc[0])+","+str(loc[1]-left_scr[1])                  subprocess.Popen(["/bin/bash", "-c", command])                  refresh = True      if all([refresh == True, check_frontmost() == True]):          subprocess.Popen(["/bin/bash", "-c", refresh_cmd])          refresh = False      dtfiles_1 = dtfiles_2  

Notes

  • Although I tested it for a long time on my system, the bug does not appear on my system, so the "real" test can only be done by you :)
  • If the desktop is really crowded with lots if items, the refresh action might arrange icons into a "forbidden" area. I could not test however if that is the case in your situation, for the same reason as above.
  • The script, as it is, assumes the screens are top-alligned, so the "blind" area is only on the left bottom corner.

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