Linux Mintで特定のファイルブラウザ(Nemo)タブのセットを常にロードすることは可能ですか? Nemoを起動するたびに、デフォルトで5つのフォルダの場所を開きたいのですが。
承認された回答:
はい、これは非常に可能です。 caja
のこのタスクには、Pythonスクリプトを使用します ブラウザ。ここでは、caja
を置き換えてスクリプトを再現しています。 nemo
を使用 。うまくいけば、それはnemo
と直接連携します それ以上の変更なし。
#!/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回発行して、nemo
をロードできます。 5つの初期タブを持つインスタンス:
#!/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