松久外吉のチラ裏

主に自分の趣味についてひっそりと書きます

工人舎PAをLubuntuで復活させた

 巷で話題のGPD WIN が欲しいっ!けど、懐事情が厳しいので、代わりに昔買ったけど使わなくなってしまった。UMPCを軽量Linuxで復活させることにした。

 そのUMPCとは「工人舎 PA3KX32SA」(以下、工人舎PA)。


一時期話題になった「UMID mbook M1」の派生製品。しかもディスプレイ(ハードウェア)が回転してタブレット(?)形態にもできる!GPD WINの表示だけ回転するのとはワケが違う!何?GPD WINにはゲームパッドが付いてる?ゲームパッドならOpenPandoraに付いてる!(卑怯)

 たが、スペックやベンチマークは比べ物にならない。Passmarkでざっくり10倍近い差が。orz RAMもGPD WINの4GBに対して工人舎PAは512MB。まあいいや。

 SSDからXPを消去して(リカバリ領域は残した)Linuxをインストールした。久しぶりにXP立ち上げたら、うっかりネットに繋がってしまって、速攻で何か感染してました。コワイ。ディストロは、非力なマシンでも動く軽いものということでPuppyも考えたけど、今回参考にさせていただいた「交流電燈舎第弐工房日誌」さんが選されていたのもあって、Lubuntuにした。バージョンは「16.04 LTS」。

 Lubuntuのインストールの前に準備したのは、USBハブとマウスとUSB-Ethernetアダプタ。最初はタッチスクリーンも内蔵の光学式ポインティングデバイスも動かないし、Ethernetポートもなく、USBポートも1つしかないので、USBハブ経由でLubuntuのUSBフラッシュメモリとマウスとUSB-Ethernetアダプタ経由でEthernetを繋いだ。

 Lubuntuのインストールから、タッチスクリーン、光学式ポインティングデバイス&マウスボタン、サスペンド&ハイバネーションを使えるようにするまで、すべて「交流電燈舎第弐工房日誌」さんの記事の通りに行った。タッチスクリーンを動かすのに、昔はプロプライエタリなeGalaxというのをインストールしたけど、今はopengalaxと言うのがあることを初めて知った。

 上記の通りインストール&設定して、いざ色々試してみると、スリープから復帰するとタッチスクリーンとマウスが死ぬ。ターミナルからopengalax を再起動してやると復帰(マウスが死んでもデフォルトのLubuntu 16.04はAlt+Ctrl+Tでターミナルを開ける)。何とかしたくて調べていると、opengalaxの開発者のものと思われるサイトを発見。そこで説明されてる設定ファイルをあーだこーだ調べてるうちに、これらはupstartのもので、Ubuntu 16.04 LTSになって、upstartがsystemdに置き換えられたことを知った。opengalaxの更新は何年か前で止まっているので、systemdには対応していないのが原因っぽい。それならopengalaxのupstart用のファイルをsystemdに翻訳してやれば良い……んだけど、ファイルの内容をよく理解できなかったので、単純にスリープから復帰したらopengalaxを再起動するようにsystemd用に以下のようなスクリプトを追加した。

/etc/systemd/system/restart_ogalax.service

[Unit]
Description=OpenGalax restart actions on resume
After=suspend.target hybrid-sleep.target hibernate.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/service opengalax restart

[Install]
WantedBy=sleep.target

そして、以下のコマンドで有効化する。

$ sudo systemctl enable restart_ogalax

 あと、せっかくディスプレイを裏返したりできるので、画面を回転するスクリプトを書いて、ショートカットキーを割り当てた。回転する方法は「InputCoordinateTransformation」を参考にした。


画面を時計回りに90度回転するスクリプト↓。
/usr/local/bin/rotate_screen_left

xrandr --output LVDS-1 --rotate left
xinput set-prop opengalax 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1
xinput set-prop opengalax-psmouse 'Coordinate Transformation Matrix' 0 -1 1 1 0 0 0 0 1

画面を反時計回りに90度回転するスクリプト↓。
/usr/local/bin/rotate_screen_right

xrandr --output LVDS-1 --rotate right
xinput set-prop opengalax 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1
xinput set-prop opengalax-psmouse 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1

画面を逆さにするスクリプト↓。
/usr/local/bin/rotate_screen_inverted

xrandr --output LVDS-1 --rotate inverted
xinput set-prop opengalax 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1
xinput set-prop opengalax-psmouse 'Coordinate Transformation Matrix' -1 0 1 0 -1 1 0 0 1

画面を元に戻すスクリプト↓。
/usr/local/bin/rotate_screen_normal

xrandr --output LVDS-1 --rotate normal
xinput set-prop opengalax 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1
xinput set-prop opengalax-psmouse 'Coordinate Transformation Matrix' 1 0 0 0 1 0 0 0 1

これらのスクリプトをOpenboxのショートカットキーに登録する。Windowsキー+1で反時計回り90度、Win+2で逆さま、Win+3で時計回り90度、Win+0で元に戻す割り当てにした。以下のファイルを変更する。

.config/openbox/lubuntu-rc.xml

このファイルの

</keybind>

</keyboard>

の間に以下を挿入。

<!-- Restart opengalax on Win + T-->
<keybind key="W-t">
<action name="Execute">
<command>sudo service opengalax restart</command>
</action>
</keybind>
<!-- Rotate the screen right on Win + 1-->
<keybind key="W-1">
<action name="Execute">
<command>/usr/local//bin/rotate_screen_left</command>
</action>
</keybind>
<!-- Rotate the screen inverted on Win + 2-->
<keybind key="W-2">
<action name="Execute">
<command>/usr/local//bin/rotate_screen_inverted</command>
</action>
</keybind>
<!-- Rotate the screen left on Win + 3-->
<keybind key="W-3">
<action name="Execute">
<command>/usr/local//bin/rotate_screen_right</command>
</action>
</keybind>
<!-- Rotate the screen normal on Win + 0-->
<keybind key="W-0">
<action name="Execute">
<command>/usr/local//bin/rotate_screen_normal</command>
</action>
</keybind>

 Webカメラは何もしなくても動いた。ワンセグチューナーは難しそう、と言うか無理なんじゃないかな。

 そんなワケで、とりあえず完成〜。

この通り、ディスプレイを回転できるぜ!


……おや?

結局、物欲に負けて買ってしまいました、GPD WIN。orz

2017年02月28日のツイート

2017年02月27日のツイート

2017年02月26日のツイート

2017年02月25日のツイート

2017年02月24日のツイート

2017年02月23日のツイート