多显示器按名称组织桌面错误

多显示器按名称组织桌面错误

我正在使用带有 Unity 的 Ubuntu 14.04LTS,并使用两个显示器:我的笔记本电脑内置显示器,1366x768 和外接显示器,分辨率为 1920x1080。

我的主显示器是内置的,因此,当我右键单击桌面并“按名称组织桌面”时,图标就会进入该桌面并对齐。

当我有许多图标需要对齐时就会出现问题,Unity 会将一些图标发送到我可见的屏幕下方,可能是考虑到更大的显示器分辨率。

我测试选择所有对齐的图标(ctrl+a)并拖到更大的显示器,但似乎隐藏的图标也相互重叠。

不管怎样,这似乎是一个错误,对吗?

我还没有检查 14.10 来查看这个问题是否已经修复。

谢谢

答案1

是的,我遇到了同样的问题..我单击“按名称组织桌面”,然后图标消失,我必须按 ctrl-A 才能将它们重新带回视图。

答案2

我写了一个脚本来更新图标的位置。无论你的屏幕分辨率是多少,这个脚本都可以使图标适合屏幕。

它很慢,在我的计算机上处​​理 100 个文件需要 1 秒多一点的时间。但至少它能工作。不过,也许有更好的方法来实现这一点……

将以下代码复制并粘贴到名为“arrange_icons.sh”的文件中。在终端中运行chmod 755 /path/to/arrange_icons.sh。使用以下命令运行脚本/path/to/arrange_icons.sh

#!/bin/bash

######################################################
## Script to automatically arrange desktop icons
## taking into account screen resolution of multiple
## monitors
######################################################

# Sort icons by...
sortby=name
# sortby=none
# sortby=time
# sortby=size
# sortby=extension
# sortby=version

# Maximum size of the grid (distance between two icons)
grid_size=85

# top, right, bottom and left margin of the screen
grid_margintop=25
grid_marginright=50
grid_marginbottom=50
grid_marginleft=50

# Filling order
# Default: fill from top to bottom, then change column from left to right
# A regular english book is written using leftright-topbottom
grid_fill=topbottom-leftright
# grid_fill=topbottom-rightleft
# grid_fill=bottomtop-leftright
# grid_fill=bottomtop-rightleft
# grid_fill=leftright-topbottom
# grid_fill=leftright-bottomtop
# grid_fill=rightleft-topbottom
# grid_fill=rightleft-bottomtop

# Find the Desktop path as it may vary from language to language
# Path to home sub-directories are located in ~/.config/user-dirs.dirs
source ~/.config/user-dirs.dirs
DESKTOP="${XDG_DESKTOP_DIR}"

# Count desktop file
icon_number=$(ls "${DESKTOP}" | wc -l)

# Find monitors, dimensions and positions, and store all icon position to temp file
tmp=/tmp/arrange_icons.position-$RANDOM$RANDOM$RANDOM
while :
do
  # Empty the file storing icon positions
  printf '' > "${tmp}"

  xrandr | grep -oE '[0-9]+x[0-9]+\+[0-9]+\+[0-9]+' | while read screen
  do
    width=$(echo ${screen} | cut -d 'x' -f 1)
    height=$(echo ${screen} | cut -d 'x' -f 2 | cut -d '+' -f 1)
    cx=$(echo ${screen} | cut -d 'x' -f 2 | cut -d '+' -f 2)
    cy=$(echo ${screen} | cut -d 'x' -f 2 | cut -d '+' -f 3)

    for px in $(seq $((cx + grid_marginleft)) ${grid_size} $((cx + grid_marginleft + width - grid_size - grid_marginright)))
    do
      for py in $(seq $((cy + grid_margintop)) ${grid_size} $((cy + grid_margintop + height - grid_size - grid_marginbottom)))
      do
        echo "${px},${py}" >> "${tmp}"
      done
    done
  done

  # Count the number of positions available with this grid
  grid_number=$(cat "${tmp}" | wc -l)

  # If it is not possible to fit every icons, try to decrease the size of the grid
  # until it fits or until the grid size reaches the minimum value (1)
  if [ ${grid_number} -lt ${icon_number} ]
  then
    grid_size=$((grid_size - 5))
    if [ ${grid_size} -lt 1 ]
    then
      grid_size=1
      break
    fi
  else
    break;
  fi
done

# Sort position according to settings
case "${grid_fill}" in
  topbottom-leftright) sort -o "${tmp}" -t, -k 1,1n -k 2,2n "${tmp}"
                       ;;
  topbottom-rightleft) sort -o "${tmp}" -t, -k 1,1rn -k 2,2n "${tmp}"
                       ;;
  bottomtop-leftright) sort -o "${tmp}" -t, -k 1,1n -k 2,2rn "${tmp}"
                       ;;
  bottomtop-rightleft) sort -o "${tmp}" -t, -k 1,1rn -k 2,2rn "${tmp}"
                       ;;
  leftright-topbottom) sort -o "${tmp}" -t, -k 2,2n -k 1,1n "${tmp}"
                       ;;
  leftright-bottomtop) sort -o "${tmp}" -t, -k 2,2rn -k 1,1n "${tmp}"
                       ;;
  rightleft-topbottom) sort -o "${tmp}" -t, -k 2,2n -k 1,1n "${tmp}"
                       ;;
  rightleft-bottomtop) sort -o "${tmp}" -t, -k 2,2rn -k 1,1n "${tmp}"
                       ;;
                    *) sort -o "${tmp}" -t, -k 1,1n -k 2,2n "${tmp}"
                       ;;
esac

# List all files on the desktop and move them to the correct location
line_number=1

# Temporary path for icon
# Moving them to /tmp folder and then moving them back to the Desktop
# is sufficient to update their position :)
tmpicon=/tmp/arrange_icons.fake-$RANDOM$RANDOM$RANDOM
([ "${sortby}" != "name" ] && ls --sort=${sortby} "${DESKTOP}" || ls "${DESKTOP}") | while read icon
do
  iconpath="${DESKTOP}/${icon}"
  coord="$(tail -n+${line_number} "${tmp}" | head -n1)"

  gvfs-set-attribute -t string "${iconpath}" 'metadata::nautilus-icon-position' "${coord}"
  mv "${iconpath}" "${tmpicon}"
  mv "${tmpicon}" "${iconpath}"

  line_number=$((line_number + 1))
done

# Cleaning
rm "${tmp}"

在我的计算机上,我设置了一个 crontab,每秒检查一次桌面文件夹。如果有任何变化,则运行上述脚本。

相关内容