![Gnome ログイン時にマウスの中ボタンのエミュレーションを有効にする (Ubuntu)](https://rvso.com/image/912797/Gnome%20%E3%83%AD%E3%82%B0%E3%82%A4%E3%83%B3%E6%99%82%E3%81%AB%E3%83%9E%E3%82%A6%E3%82%B9%E3%81%AE%E4%B8%AD%E3%83%9C%E3%82%BF%E3%83%B3%E3%81%AE%E3%82%A8%E3%83%9F%E3%83%A5%E3%83%AC%E3%83%BC%E3%82%B7%E3%83%A7%E3%83%B3%E3%82%92%E6%9C%89%E5%8A%B9%E3%81%AB%E3%81%99%E3%82%8B%20(Ubuntu).png)
私はマウスの中ボタンのエミュレーションを使うのが好きです。なぜなら、マウスの中ボタンはスクロール ホイールなので、クリックを登録するにはかなりの圧力が必要だからです。これはすぐに身体的に苦痛になります。
マウスの左ボタンと右ボタンを同時にクリックする方がはるかに簡単だと思います。この機能はいつも使っています。
~/scripts/mouse.sh
これを実行するスクリプトがあります:
#!/bin/bash
# Enable middle button emulation
# from https://askubuntu.com/a/201825/54278
if [[ -n ${DISPLAY} ]]; then
pointer1="MX Master"
id1=$(xinput | awk -F= "/$pointer1.*pointer/ {print \$2}" | cut -f1)
xinput set-prop "${id1}" "libinput Middle Emulation Enabled" 1
fi
これはうまく機能しますが、再起動するたびに手動で実行する必要があります。
を作成しました~/.config/autostart/mouse.sh.desktop
。内容は次のとおりです。
[Desktop Entry]
Type=Application
Exec=/home/david/.scripts/mouse.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_AU]=Mouse
Name=Mouse
Comment[en_AU]=Middle button emulation
Comment=Middle button emulation
私の問題は私のスクリプトはログイン時に何もしません。
中マウスボタンのエミュレーションが機能する前に、ターミナルを開いてスクリプトを実行する必要があります。
条件を削除してif [[ -n ${DISPLAY} ]]; then
、sleep
スクリプトの先頭に を追加してみました。
スクリプトの内容を に追加することも試しました~/.profile
。
どれも効果がありません。何年もの間、このことで悩んでいました。
ご覧いただきありがとうございます:-)
編集
- 私も試しました
Exec=/bin/bash /home/david/.scripts/mouse.sh
。ありがとう@PRATAP - Ubuntu 19.04ですが、18.04を含む最近のいくつかのバージョンでも動作しませんでした。
- .desktopファイルを削除し、スタートアップアプリケーションGUIを使用しようとしました
if [[ -n ${DISPLAY} ]]; then
条件を削除しようとしました- ひらめきが湧いて使ってみたが
Exec=/usr/bin/xterm -e /home/david/.scripts/mouse.sh
、やはりダメだった
答え1
私の場合は以下のスクリプトがうまくいきました
/home/user/mouse.sh
#!/bin/bash
pointer1="Logitech USB Receiver Mouse"
id1=$(xinput | awk -F= "/$pointer1.*pointer/ {print \$2}" | cut -f1)
xinput set-prop "${id1}" "libinput Middle Emulation Enabled" 1
の出力の一部xinput
$ xinput
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ ETPS/2 Elantech Touchpad id=11 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver Consumer Control id=16 [slave pointer (2)]
⎜ ↳ Logitech USB Receiver Mouse id=18 [slave pointer (2)]
/bin/bash /home/user/mouse.sh
スタートアップ アプリケーションの設定にコマンドを追加しました。