LoginSignup
24
19

More than 3 years have passed since last update.

Ubuntu16.04/18.04でマウスのホイールの回転量を調整する

Last updated at Posted at 2017-03-06

はじめに

Ubuntu16.04を使っているが、マウスのホイールの回転が小さくて困っていた。imwheelを使えばいいという情報を得たまでは良かったが、自動起動でつまずいたので、備忘録として書き記す。

imwheelの導入

$ sudo apt install imwheel

これだけで良い。

imwheelの設定

home directory( ~ )に.imwheelrcを作成する。

.imwheelrc
".*"
None,      Up,   Button4, 3
None,      Down, Button5, 2

http://pagent.github.io/2015/05/13/mouse-wheel-scroll-speed/
「Up, Button4」、「Down, Button5」の後ろの値で変更出来る。Up「3」、Down「2」で設定してみた。(デフォルトの値は「1」のよう。)
上に戻る時に早い方が良いし、この設定なら上下を繰り返すことで微調整も出来る。

とのことなので、そっくりそのまま使っている。

imwheelの起動

$ imwheel

これだけだ。

imwheelの自動起動に/etc/rc.localを使ってはいけない

http://qiita.com/lastcat_/items/0344315894db41e1836a
まず、従来のLinuxではカーネルが立ち上がったあとにinitプロセスというのが最初に立ち上がるりこれがすべてのプロセスの親プロセスになっていろんなデーモンやらを起動させていく、というプロセス(これは単に「過程」の意)を踏んでいたらしい。そして
Ubuntu 15.04以降ではこのinitプロセスにsystemdが採用されたということだ。

http://eng-entrance.com/linux_startup
現在、Linuxのシステム起動には2種の方法が混在している。

SysVinit系とsystemdの2種類だ。古くて安定的に動いているものはSysVinit系が多く、現場ではこちらに出会う確率が高い。

しかし、最近出た新しいディストリビューションでは新しいsystemdが採用されている。

というわけで、systemdが採用されている。世の中大体systemdみたいな流れらしいので、おとなしくsystemdの流儀に従う。

imwheel.serviceの作成

$ mkdir -p ~/.config/systemd/user
$ cd ~/.config/systemd/user
$ nano imwheel.service

imwheel.serviceの中身は

imwheel.service
[Unit]
Description=imwheel
Wants=display-manager.service
After=display-manager.service

[Service]
Type=simple
Environment=DISPLAY=:0.0
ExecStart=/usr/bin/imwheel
ExecStop=/usr/bin/pkill imwheel
RemainAfterExit=yes

[Install]
WantedBy=graphical.target

でよい。

systemdサービスの有効化

ここまででsystemdのサービスは作ったが、有効化していないので

$ systemctl --user list-unit-files | grep imwheel
imwheel.service                            disabled

となっているはずである。

$ systemctl --user enable imwheel.service
$ sudo loginctl enable-linger

とすることで、

$ systemctl --user list-unit-files | grep imwheel
imwheel.service                            enabled

となるはずである。試しに手動でサービスを立ち上げてみよう。

$ systemctl --user start imwheel
$ systemctl --user status imwheel
● imwheel.service - imwheel
   Loaded: loaded (/home/yumetodo/.config/systemd/user/imwheel.service; enabled; vendor preset: enabled)
   Active: active (exited) since 金 2017-03-10 22:07:31 JST; 13s ago
  Process: 4036 ExecStart=/usr/bin/imwheel (code=exited, status=0/SUCCESS)
 Main PID: 4036 (code=exited, status=0/SUCCESS)
   CGroup: /user.slice/user-1000.slice/user@1000.service/imwheel.service
           └─4037 /usr/bin/imwheel

 3月 10 22:07:31 yumetodo-desktop systemd[1200]: Started imwheel.

でうまく行くと思ったんだが、私はsystemdを理解していないようだ

あれ、うごかない
ログ→http://pastebin.com/gUa2N8Af

手動起動は、コメント欄にて @akinomyoga 氏および 某DiscordにてAruneko氏の情報提供のおかげでうまく行くようになったが、自動起動しない。なんで・・・?

追記

Ubuntu 18.04に上げたのでリベンジ。

imwheel.service
[Unit]
Description=imwheel

[Service]
Type=simple
#Environment=DISPLAY=:0
ExecStart=/usr/bin/imwheel
ExecStop=/usr/bin/pkill imwheel
RemainAfterExit=yes
Restart=always

[Install]
WantedBy=default.target

これでいけている・・・?

追記2

やっぱりどうにもsystemdのuser serviceとDISPLAY環境変数が必要な作業は相性が良くないよなぁ・・・。今見たら

$systemctl --user status imwheel.service 
● imwheel.service - imwheel
   Loaded: loaded (/home/yumetodo/.config/systemd/user/imwheel.service; enabled; vendor preset: enabled)
   Active: active (exited) since Thu 2019-05-09 11:31:15 JST; 8min ago
  Process: 2554 ExecStart=/usr/bin/imwheel (code=exited, status=0/SUCCESS)
 Main PID: 2554 (code=exited, status=0/SUCCESS)
   CGroup: /user.slice/user-1000.slice/user@1000.service/imwheel.service

 5月 09 11:31:15 yumetodo-desktop systemd[2537]: Started imwheel.
 5月 09 11:31:15 yumetodo-desktop imwheel[2554]: INFO: imwheel started (pid=2557)
 5月 09 11:31:15 yumetodo-desktop imwheel[2554]: Could not open display, check shell DISPLAY variable, and export or setenv it!

とか言われているし・・・。

でやってるみたいにgnomeの自動起動機構を使うほうが良さそう。

License

CC BY 4.0

CC-BY icon.svg

24
19
8

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
19