Linux MintにNemoタブを保存する

Linux MintにNemoタブを保存する

Linux Mintで特定のファイルブラウザ(Nemo)タブセットを常にロードできますか? Nemoを起動するたびに、デフォルトで5つのフォルダの場所を開くようにしたいと思います。

ベストアンサー1

はい、可能です。私はこれを行うためにブラウザでPythonスクリプトを使用しますcajacajaに置き換えて、ここにスクリプトをコピーしましたnemonemoこれ以上の変更なしで正常に動作できることを願っています。

#!/usr/bin/env python3
import subprocess
import time
import sys

get = lambda cmd: subprocess.check_output(["/bin/bash", "-c", cmd]).decode("utf-8")
def run(cmd):
    subprocess.call(["/bin/bash", "-c", cmd])

try:
    arg = sys.argv[1]
except:
    arg = ""

try:
    pid = get("pidof nemo").strip()
except subprocess.CalledProcessError:
    run("nemo "+arg)
else:
    w = [l.split() for l in get("wmctrl -lp").splitlines() if pid in l][-1]
    w_id = w[0]   
    if len( [l for l in get("xprop -id "+w_id).splitlines() if all(
        ["_NET_WM_WINDOW_TYPE(ATOM)" in l, "_TYPE_NORMAL" in l])]) != 0:
        run("wmctrl -ia "+w[0])
        run("xdotool key Control_L+t")
        if arg != "":
            run("xdotool key Control_L+l")
            time.sleep(0.2)
            run("xdotool type "+arg)
            time.sleep(0.01*len(arg))
            run("xdotool key Return")
    else:
        run("nemo "+arg)

このスクリプトをユーザーディレクトリまたはパスの別のディレクトリnemo-tab.pyに保存します。~/bin実行可能にしてください。その後、このスクリプトを実行すると、現在実行中のブラウザで新しいタブが開き、実行nemo中のインスタンスがない場合は新しいブラウザが起動します。次のように実行します。

nemo-tab.py "~/Documents"

これで、bashスクリプトでコマンドを5回実行して、nemo5つの初期タブを持つインスタンスをロードできます。

#!/bin/bash
nemo-tab.py "~/Documents"
nemo-tab.py "~/Desktop"
nemo-tab.py "~/media/data"
nemo-tab.py "~/Videos"
nemo-tab.py "~/Pictures"

xdotool以下をインストールする必要がありますwmctrl

sudo apt-get install xdotool wmctrl

Pythonスクリプトソース:https://askubuntu.com/questions/628084/what-is-the-command-to-open-a-specific-directory-in-a-new-tab-in-nautilus

おすすめ記事