디렉토리 트리에 대해 노틸러스보기 모드를 재귀 적으로 설정하려면 어떻게합니까? 설정을 기억합니다. 내가

노틸러스 3.4에서는 기본보기 모드 를 설정할 수 있습니다 . 또한 특정 폴더에 대한 사용자 정의보기 설정을 기억합니다.

내가 할 수있는 것은 특정 디렉토리 트리에서 모든 디렉토리와 하위 디렉토리에 대한보기 모드를 정의하는 것입니다. 보기 모드를 수동으로 변경하기 위해 각각의 모든 폴더를 살펴보면 너무 오래 걸릴 수 있습니다.

내가 할 수있는 방법이 있습니까? 아마도 gvfs-metadata 를 수정하는 노틸러스 스크립트를 통해 ?



답변

개요

폴더의 메타 데이터를 찾으려면 다음 명령을 사용해야합니다 gvfs-info foldername

예를 들어 gvfs-info /home/homefolder/Desktop

리턴되는 목록 metadata::nautilus-default-view에는 기본보기를 설명하는 속성이 표시됩니다 .

명령을 사용하여이 속성을 변경할 수 있습니다 gvfs-set_attribute foldername attribute newvalue

예를 들면 다음과 같습니다.

gvfs-set-attribute /home/homefolder/Desktop "metadata::nautilus-default-view" "OAFIID:Nautilus_File_Manager_Icon_View"

스크립트

이제 내 bash 스크립팅 기술이 최고가 아니라는 것을 인정해야하지만 여기에 있습니다. 아래의 스크립트를 사용하면 주어진 폴더 이름 아래의 모든보기를 재설정 할 수 있습니다.

통사론:

folderreset [OPTION] full_base_directory_name

예를 들어 이것은 아래의 모든 폴더를 콤팩트로 볼 수 있도록 재설정됩니다 /home/homefolder/Desktop

folderreset -c /home/homefolder/Desktop

folderreset -h구문에 사용 하십시오.

땜질하고 수정하십시오.


#!/bin/bash

#Licensed under the standard MIT license:
#Copyright 2013 fossfreedom.
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

################################ USAGE #######################################

usage=$(
cat <<EOF
Usage:
$0 [OPTION] base_full_directory_name

 -h, --help     display this help
 -l, --list     set to list view
 -i, --icon     set to icon view
 -c, --compact  set to compact view

for example

$0 -i /home/myhome/Desktop

This will reset all directories BELOW /home/myhome/Desktop

EOF
)

########################### OPTIONS PARSING #################################

#parse options
TMP=`getopt --name=$0 -a --longoptions=list,icon,compact,help -o l,i,c,h -- $@`

if [[ $? == 1 ]]
then
    echo
    echo "$usage"
    exit
fi

eval set -- $TMP

#default values
META=OAFIID:Nautilus_File_Manager_List_View

until [[ $1 == -- ]]; do
    case $1 in
        -l|--list)
            META=OAFIID:Nautilus_File_Manager_List_View
            ;;
        -i|--icon)
            META=OAFIID:Nautilus_File_Manager_Icon_View
            ;;
        -c|--compact)
            META=OAFIID:Nautilus_File_Manager_Compact_View
            ;;
        -h|--help)
            echo "$usage"
            exit
            ;;
    esac
    shift # move the arg list to the next option or '--'
done
shift # remove the '--', now $1 positioned at first argument if any

if [ ! -d "$1" ]
then
        echo "Directory does not exist!"
        exit 4
fi

find "$1"/* -type d | while read "D"; do gvfs-set-attribute "$D" "metadata::nautilus-default-view" "$META" &>/dev/null; done

GUI 래퍼

다음은 노틸러스 스크립트 컨텍스트 메뉴에서 바로보기 모드를 설정하는 데 사용할 수있는 간단한 GUI 래퍼 스크립트입니다.

#!/bin/bash

# Licensed under the standard MIT license
# (c) 2013 Glutanimate (http://askubuntu.com/users/81372/)

FOLDERRESET="./folderreset.sh"
WMICON=nautilus
THUMBICON=nautilus
WMCLASS="folderviewsetter"
TITLE="Set folder view"

DIR="$1"

checkifdir(){
if [[ -d "$DIR" ]]
  then
      echo "$DIR is a directory"
  else
      yad --title="$TITLE" \
          --image=dialog-error \
          --window-icon=dialog-error \
          --class="$WMCLASS" \
          --text="Error: no directory selected." \
          --button="Ok":0
      exit
fi
}

setviewtype (){
VIEWTYPE=$(yad \
    --width 300 --entry --title "$TITLE" \
    --image=nautilus \
    --button="ok:2" --button="cancel" \
    --text "Select view mode:" \
    --entry-text \
    "list" "icon" "compact")

 if [ -z "$VIEWTYPE" ]
   then
       exit
 fi

}


checkifdir
setviewtype

"$FOLDERRESET" --"$VIEWTYPE" "$DIR"

스크립트 yad이 PPA 에서 설치할 수있는 정력 포크에 따라 다릅니다 . 시스템 FOLDERRESET=에서 folderreset스크립트 의 위치 를 가리켜 야 합니다.


답변