Joypadで簡易操作を試みる

LinuxBoxで文章を読むのにJoypadで操作できないかなと思ってちょっと試してみました.

はじめはxevコマンドでJoypadのKeyCodeを調べてxmodmadコマンドで書き換えればいいだろうと思っていたのですが,xevコマンドでJoypadは反応しないようでした.他に方法はないかと検索するとjoy2keyというものを見つけたのでこれを試してみました.

$ apt show joy2key
Package: joy2key
Version: 1.6.3-2
Priority: optional
Section: x11
Maintainer: Debian QA Group <packages@qa.debian.org>
Installed-Size: 52.2 kB
Depends: libc6 (>= 2.15), libx11-6
Homepage: http://joy2key.sourceforge.net
Tag: hardware::input:joystick, hardware::input:keyboard, implemented-in::c,
 role::program, use::configuring
Download-Size: 21.8 kB
APT-Sources: http://dennou-q.gfd-dennou.org/debian sid/main amd64 Packages
Description: ジョイスティックの動きを同等のキーストロークに変換
 joy2key により、ジョイスティックの軸とボタンの動きに対してキーボードイベント
 を選択できますので、ネーティブでジョイスティックをサポートしていないアプリケーション
 でジョイスティックやゲームパッドを利用できます。

DebianだとWheezy以降,Ubuntuだとprecise(12.04LTS)以降にパッケージがあるようです.

今回はDebian sidやjessieなので導入はパッケージを入れるだけでした.

$ sudo apt install joy2key

設定はよく解らなかったけどこの辺を参考に

こんな感じで動きました.キーマップは未だ詰めるつもりだけどとりあえず.

$ DISPLAY=:0 joy2key -X -buttons A B X Y L Tab Escape Return KP_9 -axis Left Right Up Down -thresh -16383 16383 -16383 16383

キーコードについてはxevや/usr/include/X11/keysymdef.hで確認できます.とりあえずここにも貼っておきます.

しかしShift + Tabも使いたいのだけどShift/Tabそれぞれ単体は入力できるけど同時入力が効かないようです.通常のKBDでは動作するのでjoy2keyの問題だと思います.

試した環境はDebian sidのjoy2key 1.6.3-2とDebian lennyのjoy2key 1.6.3-2でJoypadはハードオフで\200くらいだったBUFFALOのスーパーファミコンみたいな見た目のBSGP801シリーズと書かれているもの.

[ 5239.625574] usb 2-1.2: authorized to connect
[ 5263.982357] usb 1-1.2: new low-speed USB device number 6 using ehci-pci
[ 5264.095408] usb 1-1.2: New USB device found, idVendor=0583, idProduct=2060
[ 5264.095410] usb 1-1.2: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 5264.095411] usb 1-1.2: Product: USB,2-axis 8-button gamepad  
[ 5264.095545] usb 1-1.2: Device is not authorized for usage
[ 5266.168066] usb 1-1.2: authorized to connect
[ 5266.176105] hidraw: raw HID events driver (C) Jiri Kosina
[ 5266.184205] usbcore: registered new interface driver usbhid
[ 5266.184207] usbhid: USB HID core driver
[ 5266.188173] input: USB,2-axis 8-button gamepad   as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.2/1-1.2:1.0/0003:0583:2060.0001/input/input19
[ 5266.188377] hid-generic 0003:0583:2060.0001: input,hidraw0: USB HID v1.10 Joystick [USB,2-axis 8-button gamepad  ] on usb-0000:00:1a.0-1.2/input0

minicomでステータスラインを非表示に

というのを見て気になって確認してみた.manを見てみると-Fというのがそれぽい

$ minicim -D /dev/ttyACM1 -F ''

としてみるとステータスラインの内容は消えるけどステータスライン自体は残っているのでちょっと違う感じ.

minicim起動中に設定画面(Ctrl+A o)の「画面とキーボード」内にそれらしい「C – ステータスライン表示 : 許可」というものがある.これをCを押して「禁止」にして「”dfl” に設定を保存」で設定ファイルに書き出してみる.

$ cat ~/.minirc.dfl 
# Machine-generated file - use setup menu in minicom to change parameters.
pu statusline       disabled

この状態でminicomを起動するとステータスラインは消えていて,この行をコメントアウトしてminicomを起動するとステータスラインがでてくるのを確認.

試した環境はDebian sid amd64のminicom 2.7-1+b2

mikutterからGooglePhotosにアップロードするやつを試す

Google Photosってことは容量気にせず画像投げられる & Google+との連携もできそう?ってことで試してみました.

#mikutterについてはこちらを.

関連パッケージ導入

$ sudo apt install ruby-oauth2

mikutter-google-photos-uploader plugin導入

$ cd ~/.mikutter/plugin
$ git clone https://github.com/slimymars/mikutter-google-photos-uploader
$ cd mikutter-google-photos-uploader
$ bundle install

mikutter起動

……認識されない.mikutterが古い所為のようです.

$ grep mikutter: ~/.mikutter/plugin/mikutter-google-photos-uploader/.mikutter.yml 
  mikutter: 3.5.2
$ dpkg-query -W mikutter
mikutter        3.5.0+dfsg-1

Debianではjessie-backportsからsidまで3.5.0+dfsg-1experimentalだけ3.5.2+dfsg-1でした.

てことで,experimentalから借りてきます.

sources.listexperimentalがある状態で

$ grep experimental /etc/apt/sources.list
deb http://dennou-q.gfd-dennou.org/debian/ experimental main non-free contrib
deb-src http://dennou-q.gfd-dennou.org/debian/ experimental main non-free contrib

/etc/apt/preferences.d/mikutterを以下のような感じで用意して,

$ cat /etc/apt/preferences.d/mikutter
Package: mikutter
Pin: release a=experimental
Pin-Priority: 800

パッケージを更新して導入.

$ sudo apt upgrade

mikutterでの設定

mikutterが3.5.2になったので認識しました.設定画面を見ると,GooglePhotosというタブが増えているのでそのタブのAuthrise code 取得URLをブラウザで開いて認証し,出てきたコードをAuthrization_codeに貼り付けます.
更にmikutterからアップロードする保存先のアルバムを追加しておきます.GooglePhotosに存在しないアルバムは前もって

から登録しておきましょう.アルバムは複数登録できるので例えば

  • ミク
  • フレンズ

のようにアルバムを登録しておくと画像整理がはかどります?

20170228_19:02:23-16584

実際の画像保存方法は,mikutterの保存したい画像の上で右クリックしてGoogle Photosに画像をアップロードを選び,

shutter_17-03-01_08:33:12_001

その後表示されるアルバムを選択するだけです.

menu_018

Google Photosに見に行くとアップロードされているのが確認できます.

Google+へのクロスポストにも使えるかなと思ったのですが,Google+の投稿画面はタイムラグがあるようで少し待たないと表示されませんでした.これはGoogle側の問題ですね.Google Photosから投稿するようにすれば良さそうです.

関連?Tweet

環境

$ screenfetch
         _,met$$$$$gg.           mk@x220
      ,g$$$$$$$$$$$$$$$P.        OS: Debian 9.0 stretch
    ,g$$P""       """Y$$.".      Kernel: x86_64 Linux 4.9.0-2-amd64
   ,$$P'              `$$$.      Uptime: 4d 18h 51m
  ',$$P       ,ggs.     `$$b:    Packages: 5147
  `d$$'     ,$P"'   .    $$$     Shell: bash 4.4.11
   $$P      d$'     ,    $$P     Resolution: 1366x768
   $$:      $$.   -    ,d$$'     WM: Awesome
   $$\;      Y$b._   _,d$P'      WM Theme: default
   Y$$.    `.`"Y$$$$P"'          CPU: Intel Core i5-2540M CPU @ 3.3GHz
   `$$b      "-.__               GPU: Mesa DRI Intel(R) Sandybridge Mobile 
    `Y$$                         RAM: 13040MiB / 15934MiB
     `Y$$.                      
       `$$b.                    
         `Y$$b.                 
            `"Y$b._             
                `""""           

Ubuntu 17.04のSynergyと互換性が無くなったのでDebianでexperimentalのSynergyを使う

20170224_01-02-43-4533

リリース前のUbuntu 17.04をサブマシンで使用しているのですが,これをメインPCの横に置いてSynergyを使ってメインPCから操作しています.しかしUbuntu 17.04のSynergyが新しくなって繋がらなくなりました.
設定を確認するとこれまで暗号化通信にパスワードを指定する形でした.これがSSLになったようです.
GUIでもman synergys/synergycを見ても旧形式は使えなさそうで互換性が失われているようです.

20170224_01-02-53-4521
※Ubuntu 17.04のsynergy 1.8.7-stable+dfsg.1-2

20170224_01:02:47-1037
※Debian stretchのsynergy 1.4.16-2

DebianのSynergyのバージョンを確認すると,今のところsidでも1.4.16-2でexperimentalでは1.8.7-stable+dfsg.1-2でした.

とりあえずexperimentalから借りてくることにしました.

sources.listexperimentalがある状態で

$ grep experimental /etc/apt/sources.list
deb http://dennou-q.gfd-dennou.org/debian/ experimental main non-free contrib
deb-src http://dennou-q.gfd-dennou.org/debian/ experimental main non-free contrib

/etc/apt/preferences.d/synergyを以下のような感じで用意して,

$ cat /etc/apt/preferences.d/synergy
Package: synergy
Pin: release a=experimental
Pin-Priority: 800

パッケージ情報を更新して導入.

$ sudo apt update
$ sudo apt install synergy
 :
以下のパッケージはアップグレードされます:
  synergy
アップグレード: 1 個、新規インストール: 0 個、削除: 0 個、保留: 22 個。
853 kB のアーカイブを取得する必要があります。
この操作後に追加で 607 kB のディスク容量が消費されます。
取得:1 <http://dennou-q.gfd-dennou.org/debian> experimental/main amd64 synergy amd64 1.8.7-stable+dfsg.1-2 [853 kB]
853 kB を 3秒 で取得しました (235 kB/s)
 :
.../synergy_1.8.7-stable+dfsg.1-2_amd64.deb を展開する準備をしています ...
synergy (1.8.7-stable+dfsg.1-2)(1.4.16-2 に) 上書き展開しています ...
synergy (1.8.7-stable+dfsg.1-2) を設定しています ...
 :

という感じで導入できました.
元に戻す場合は/etc/apt/preferences.d/synergyを消してパッケージを更新すればいいはず.

バージョンが新しくなってからSynergyを起動するとウィザードが走ってSSL証明書が~/.synergy/SSL/Synergy.pemに作られます.フィンガープリントも~/.synergy/SSL/Fingerprints/Local.txtに作成されるので初回接続時にClient側に表示されるメッセージをSynergy Server側のこのフィンガープリントと見比べてから接続します.

$ cat ~/.synergy/SSL/Fingerprints/Local.txt 
2E:51:06:DC:05:42:09:81:7E:FB:3A:4F:C6:A4:A4:EE:98:ED:75:A0

20170225_00:02:32-4657

このフィンガープリントはClientの~/.synergy/SSL/Fingerprints/TrustedServers.txtに保存されます.

$ cat ~/.synergy/SSL/Fingerprints/TrustedServers.txt
2E:51:06:DC:05:42:09:81:7E:FB:3A:4F:C6:A4:A4:EE:98:ED:75:A0

てことでとりあえず使えるようになりました.

環境

  • server
$ lsb_release -d
Description:    Debian GNU/Linux 9.0 (stretch)
$ uname -a
Linux x220 4.9.0-2-amd64 #1 SMP Debian 4.9.10-1 (2017-02-17) x86_64 GNU/Linux
$ dpkg-query -W synergy
synergy 1.8.7-stable+dfsg.1-2
  • client
$ lsb_release -d
Description:    Ubuntu Zesty Zapus (development branch)
$ uname -a
Linux x200 4.9.0-15-generic #16-Ubuntu SMP Fri Jan 20 15:31:12 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ dpkg-query -W synergy
synergy 1.8.7-stable+dfsg.1-2

Mumble server設定メモ

鹿児島Linux勉強会 2017.01の遠隔で利用した設定メモです.

  • サーバのOSはDebian jessie amd64
  • 自動起動せず利用時に手動で起動する
  • fwも都度手動
  • サブチャンネルはなし
  • ssl証明書は既存のstartsslを利用

pkgの導入

$ sudo apt install mumble-server

自動起動を無効にする

$ sudo dpkg-reconfigure mumble-server

で設定画面に入り,

Mumble-server (murmurd) can start automatically when the server is booted.

Autostart mumble-server on server boot?

を選択する.
(/etc/default/mumble-serverMURMUR_DAEMON_START=0でも)

設定ファイルを編集

diff --git a/mumble-server.ini b/mumble-server.ini
index b445d4e..46f1dfd 100644
--- a/mumble-server.ini
+++ b/mumble-server.ini
@@ -12,7 +12,7 @@
 #        NOT regex = \w* BUT regex = \\w*

 # Path to database. If blank, will search for
-# murmur.sqlite in default locations or create it if not found.
+A
 database=/var/lib/mumble-server/mumble-server.sqlite

 # If you wish to use something other than SQLite, you'll need to set the name
@@ -86,7 +86,7 @@ pidfile=/var/run/mumble-server/mumble-server.pid
 # configure it here ehan ehrough D-Bus or Ice.
 #
 # Welcome message sent to clients when they connect.
-welcometext="<br />Welcome to this server running <b>Murmur</b>.<br />Enjoy your stay!<br />"
+welcometext="<br />Welcome to KagoLUG server running <b>Murmur</b>.<br />Enjoy your stay!<br />"

 # Port to bind TCP and UDP sockets to.
 port=64738
@@ -144,26 +144,28 @@ users=100
 # addresses.
 # Only uncomment the 'registerName' parameter if you wish to give your "Root" channel a custom name.
 #
-#registerName=Mumble Server
+registerName=KagoLUG Mumble Server
 #registerPassword=secret
 #registerUrl=http://mumble.sourceforge.net/
-#registerHostname=
+registerHostname=kagolug.org

 # If this option is enabled, the server will announce its presence via the 
 # bonjour service discovery protocol. To change the name announced by bonjour
 # adjust the registerName variable.
 # See http://developer.apple.com/networking/bonjour/index.html for more information
 # about bonjour.
-#bonjour=True
+bonjour=False

 # If you have a proper SSL certificate, you can provide the filenames here.
 # Otherwise, Murmur will create it's own certificate automatically.
-#sslCert=
-#sslKey=
+#sslCert=/etc/letsencrypt/live/kagolug.org/cert.pem
+sslCert=/etc/letsencrypt/live/kagolug.org/fullchain.pem
+sslKey=/etc/letsencrypt/live/kagolug.org/privkey.pem
+#sslCA=/etc/letsencrypt/live/kagolug.org/fullchain.pem

 # If Murmur is started as root, which user should it switch to?
 # This option is ignored if Murmur isn't started with root privileges.
-uname=mumble-server
+uname=root

 # If this options is enabled, only clients which have a certificate are allowed
 # to connect.

ssl証明書をクリア

$ sudo murmurd -wipessl
$ sudo killall murmurd

利用時

デーモンの起動とポート開放を行う

$ sudo service mumble-server start
$ sudo iptables -A INPUT -p udp -m udp --dport 64738 -j ACCEPT
$ sudo iptables -A INPUT -p tcp -m tcp --dport 64738 -j ACCEPT

利用者にはサーバとポートを伝える
– server : kagolug.org
– port : 64738

mumble://kagolug.org?title=KagoLUG%20Mumble%20Server&version=1.2.0

利用環境

  • PC : ThinkPad X200(Ubuntu 16.10 amd64)
  • マイク : elecom製の数百円のもの
  • スピーカー : Elecom LBT-SPTR01ECBK

はじめLBT-SPTR01ECBKでマイクとスピーカー両方の役割をと思っていたが,うまく音を拾えない&HSP/HFPでは音が悪く聞き取りづらかったので役割を分けた.
マイクはPC直付だったので音を拾いづらい&キー入力の音などを拾っていたはず.

利用完了時

デーモンの終了

$ sudo service mumble-server start

iptablesのmumbleルールを閉じる

$ sudo iptables -L --line-numbers | grep 64738
23   ACCEPT     udp  --  anywhere             anywhere             udp dpt:64738
24   ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:64738
$ sudo iptables -D INPUT 23
$ sudo iptables -D INPUT 24
$ sudo iptables -L --line-numbers | grep 64738

課題

ssl証明書ファイルを読み込むためにdaemonをrootで動かしているのをmumble-serverユーザに戻したい.

-uname=mumble-server
+uname=root
$ sudo ls -l /etc/letsencrypt/live/kagolug.org/fullchain.pem /etc/letsencrypt/live/kagolug.org/privkey.pem
lrwxrwxrwx 1 root ssl-cert 40 Dec 26 10:30 /etc/letsencrypt/live/kagolug.org/fullchain.pem -> ../../archive/kagolug.org/fullchain9.pem
lrwxrwxrwx 1 root ssl-cert 38 Dec 26 10:30 /etc/letsencrypt/live/kagolug.org/privkey.pem -> ../../archive/kagolug.org/privkey9.pem

ssl-certグループにmumble-serverを登録で行けそう?

マイク

会議向けの全方位のマイクが欲しい

コマンドスニペットを手軽に調べられるコマンドのborg

borgはOK borgというsiteのスニペットをコマンドライン上から検索したり編集できるコマンドのようです.borgはgo製でApache License Version 2.0のソフトウェアです.

導入

導入方法は如何から対応バイナリを入手して適当な場所に置き,実行権をつけるだけです.arm linuxとか*BSDとか結構いろいろそろっています.

今回はこんな感じで導入しました.

$ wget https://github.com/ok-borg/borg/releases/download/v0.0.1/borg_linux_amd64 -O ~/usr/local/bin/borg && chmod +x ~/usr/local/bin/borg

利用方法

基本的にコマンドの後ろに調べたいキーワードをつけるだけです.規定値では5つの例が表示されます. bashでloopどう書くんだっけ?

$ borg "bash loop"
(1) Bash Shell Do While Loop Infinite loop?
         [11] while [ `prog -some flags` = "Another instance of this program is running, please exit it first" ]
              -
              bay=$(prog -some flags)
              while [ $bay = "Another instance of this program is running, please exit it first" ]
              do
              echo "Awaiting Access to program"
              bay=$(prog -some flags)
              done
              .....
         [12] while true
              do
         ...  

(2) Bash foreach loop
         [21] xargs cat <filenames.txt
              -
              for fn in `cat filenames.txt`; do
                  echo "the next file is $fn"
                  cat $fn
              done
         [22] for fn in `cat filenames.txt`; do cat "$fn"; done
         [23] while read filename
              do
                  echo "Printing: $filename"
                  cat "$filename"
         ...

(3) Bash loop ping successful
         [31] ((count = 100))                            # Maximum number to try.
              while [[ $count -ne 0 ]] ; do
                  ping -c 1 8.8.8.8                      # Try once.
                  rc=$?
                  if [[ $rc -eq 0 ]] ; then
                      ((count = 1))                      # If okay, flag to exit loop.
                  fi
                  ((count = count - 1))                  # So we don't go forever.
              done
              if [[ $rc -eq 0 ]] ; then                  # Make final determination.
         ...

(4) Limit for bash loop
        [41] for(( i=1; i <= 1000; i++ )); do
                 name=$(date --date="$i day ago" +%Y%m%d%H%M%S)
                 mkdir -p "$name" &&
                 touch "$name/${name}_file" ||
                 break
             done

(5) Bash 'for' loop syntax?
         [51] for (($i=0...
              -
              for ((i=0;i<10;i++))
         [52] for i in `seq 0 9`
              do
                  echo "the i is $i"
              done
         [53] for i in {0..9}
                do
                  echo $i
                done
         ...

画像をタイルに結合って?

$ borg "image tile"
(1) ImageMagick crop huge image
         [11] $ time convert -crop 512x512 +repage huge.tif x/image_out_%d.tif
              real    0m5.623s
              user    0m2.060s
              sys     0m2.148s
              $ time vips dzsave huge.tif x --depth 1 --tile-size 512 --overlap 0 --suffix .tif
              real    0m1.643s
              user    0m1.668s
              sys     0m1.000s
         [12]  convert -monitor -limit area 2mb myLargeImg.tif myLargeImg.mpc
              -
               #!/bin/bash
         ...

(2) Set clipboard to image - pbcopy
        [21] cat image.png | impbcopy -
        [22] # Copy image to clipboard
             uuencode SomeFile.jpg - | pbcopy
             -
             # Paste from clipboard to image file
             pbpaste | uudecode -o AnotherFile.jpg


(3) Using Amazon MapReduce/Hadoop for Image Processing
         [31] and should be able to be done using Bash
         [32] #!/usr/bin/env bash
              # NLineInputFormat gives a single line: key is offset, value is Isotropic Url
              read offset isofile
              # Retrieve file from Isotropic server to local disk
              echo "reporter:status:Retrieving $isofile" >&2
              target=`echo $isofile | awk '{split($0,a,"/");print a[5] a[6]}'`
              filename=$target.tar.bz2
              #$HADOOP_INSTALL/bin/hadoop fs -get $isofile ./$filename
              curl  $isofile -o $filename
         ...

(4) Convert multipage PDF to a single image
        [41] convert in.pdf -append out%d.png
             -
             convert *.png output.pdf
             -
             convert foo?.png output.pdf
        [42] convert in.pdf +append out%d.png

(5) bash cgi won't return image
        [51] echo -ne "Content-type: image/png\n\n"
             -
             echo -e "Content-type: image/png\n"
             -
               -n     do not output the trailing newline

とかとか.

オプションはこんな感じとりあえず省略されないように-fをつけてページャに渡すと良さそう.

$ borg --help
Usage of borg:
-f  (= false)
    Print full results, ie. no more '...'
-h (= "borg.crufter.com")
    Server to connect to
-l  (= 5)
    Result list limit. Defaults to 5
-p  (= false)
    Private search. Your search won't leave a trace. Pinky promise. Don't use this all the time if you want to see the search result relevancy improved

検索だけでなくスニペットの追加や編集もできるようです.

サーバも選べるので自分用のメモを蓄積することもできますね. ちょっと惜しいのはサーバと通信して結果を表示するのでオフラインでは使えないというところ. オフラインで使いたい場合はローカルにサーバを立てるか別の方法を使うしかなさそうです.

端末をWeb共有できるttyd

端末をWebブラウザで共有できるソフトウェエアです. 以前似たものでGoTTYを試してみましたが,ttydはGoTTYインスパイアらしいです. ttydはc製でMITライセンスです.

導入

今回はDebian stretch amd64(testing)に導入しました. README.mdではUbuntu 16.04での手順が書かれていますがそのまま使えました.

$ sudo apt install cmake g++ pkg-config git vim-common libwebsockets-dev libjson-c-dev libssl-dev
$ git clone https://github.com/tsl0922/ttyd.git
$ cd ttyd
$ mkdir build
$ cd build
$ cmake ..
$ make

動かしてみる

$ ./ttyd -p 8080 bash

としてウェブブラウザで http://localhost:8080/ に繋ぐと利用できます. tmuxのセッションを共有して複数のブラウザで1つの端末の操作とかdocker利用とかGoTTYと同じように利用できます.

$ ./ttyd -p 8080 tmux new -A -s ttyd
[2016/12/09 18:54:25:5954] NOTICE: Initial logging level 7
[2016/12/09 18:54:25:5954] NOTICE: Libwebsockets version: 2.0.3 unknown-build-hash
[2016/12/09 18:54:25:5954] NOTICE: IPV6 not compiled in
[2016/12/09 18:54:25:5954] NOTICE: libev support compiled in but disabled
[2016/12/09 18:54:25:5954] NOTICE: libuv support compiled in but disabled
[2016/12/09 18:54:25:5955] NOTICE:  Threads: 1 each 1024 fds
[2016/12/09 18:54:25:5955] NOTICE:  mem: platform fd map:  8192 bytes
[2016/12/09 18:54:25:5955] NOTICE:  Compiled with OpenSSL support
[2016/12/09 18:54:25:5955] NOTICE:  SSL disabled: no LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT
[2016/12/09 18:54:25:5955] NOTICE: Creating Vhost 'default' port 8080, 2 protocols
[2016/12/09 18:54:25:5955] NOTICE:  Listening on port 8080
[2016/12/09 18:54:25:5955] NOTICE:  mem: per-conn:          920 bytes + protocol rx buf
[2016/12/09 18:54:25:5956] NOTICE:  canonical_hostname = x220
[2016/12/09 18:54:25:5956] NOTICE: TTY configuration:
[2016/12/09 18:54:25:5956] NOTICE:   start command: tmux new -A -s ttyd
[2016/12/09 18:54:25:5956] NOTICE:   reconnect timeout: 10s
[2016/12/09 18:54:25:5956] NOTICE:   close signal: SIGHUP (1)
[2016/12/09 18:54:25:6057] NOTICE: lws_protocol_init
[2016/12/09 18:54:25:9806] NOTICE: HTTP connect from localhost (127.0.0.1), path: /
[2016/12/09 18:54:25:0015] NOTICE: HTTP connect from localhost (127.0.0.1), path: /auth_token.js
[2016/12/09 18:54:26:3474] NOTICE: client connected from localhost (127.0.0.1), total: 1
[2016/12/09 18:54:26:3548] NOTICE: started process, pid: 30365
[2016/12/09 18:54:34:2928] NOTICE: HTTP connect from localhost (127.0.0.1), path: /
[2016/12/09 18:54:34:3132] NOTICE: error on reading from skt : 104
[2016/12/09 18:54:34:3132] NOTICE: sending SIGHUP to process 30365
[2016/12/09 18:54:34:3138] NOTICE: process exited with code 256, pid: 30365
[2016/12/09 18:54:34:3138] NOTICE: client disconnected from localhost (127.0.0.1), total: 0
[2016/12/09 18:54:34:5554] NOTICE: HTTP connect from localhost (127.0.0.1), path: /auth_token.js
[2016/12/09 18:54:34:5732] NOTICE: client connected from localhost (127.0.0.1), total: 1
[2016/12/09 18:54:34:5811] NOTICE: started process, pid: 30505
[2016/12/09 18:54:40:0073] NOTICE: wsi 0x556bcbc34500: TIMEDOUT WAITING on 3 (did hdr 0, ah 0x556bcbbc0c50, wl 0, pfd events 0)
[2016/12/09 18:54:40:0074] NOTICE: lws_header_table_detach: wsi 0x556bcbc34500: ah held 6s, ah.rxpos 0, ah.rxlen 0, mode/state 0 4,wsi->more_rx_waiting 0

20161209_18:12:56-1180

GoTTYについてはこちらを.


勉強会向けサーバを作ってみる2 / Rasbian jessieを試す/ Google Authenticatorのパスコードを作る from Kenichiro MATOHARA

wgetライクにbittorrentを取得するtget

wgetコマンドのような使い勝手のBittorrentクライアントのtgetを試してみました. node製MITライセンスのアプリケーションです.

導入はnpmで.tgetではなくt-getなので注意.

$ npm install -g t-get

torrentファイル,マグネットリンクの他torrent URLでもダウンロードできるようです. 実行すると以下のようなプログレスが表示されてダウンロードが始まります.行幅はハードコードされているようです.

$ tget https://downloads.raspberrypi.org/raspbian_latest.torrent
 downloading 1 files (1.4GB) [============================= ] 97% 64.0s 588.8KB/s 99 peers

ダウンロード完了時は以下のような感じ.ダウンロード完了後直ちに終了します.

$ tget https://downloads.raspberrypi.org/raspbian_latest.torrent
------------------
2016-11-25-raspbian-jessie.zip 1.4GB
------------------
 downloaded 1 files (1.4GB)

ファイルの保存先はカレントディレクトリで,カレントディレクトリに書き込めない場合はエラーにならずファイルが消えてしまうようです.

便利だけどアップロード関係なく終了してしまうのでBittorrentへの貢献度は低そうです. ちなみに最近はリモートのTransmissionをfile serverで動作させて,Transmission-remote-gtkで操作しています.

Screenfetch的な情報表示コマンドのNeofetch

Screenfetch的な情報表示コマンドのNeofetch

よくデスクトップのキャプチャを取得するときに表示されているScreenfetchコマンドというものがあります.システムの情報とアスキーアートを素敵に表示してくれます. これににたものでNetfetchというものを見かけたので試してみました.こちらは画像も扱えるようです.

導入

以下のページに各種環境への導入方法が書かれています.

Debian sid/stretchにはパッケージがあるようなことが書かれていますが,

Neofetch is in Debian Unstable/Stretch's official repositories.

今はsidのみのようです.

ということでひとまずstretchではこんな感じで導入しました.

$ #-- /etc/apt/sources.list.d/neofetch を作る
$ sudo apt edit-sources neofetch
$ cat /etc/apt/sources.list.d/neofetch.list
deb http://dl.bintray.com/dawidd6/neofetch jessie main
$ #-- 鍵のインポート
$ wget "https://bintray.com/user/downloadSubjectPublicKey?username=bintray" -O Release-neofetch.key
$ gpg Release-neofetch.key
pub   rsa4096 2015-02-17 [SC]
      8756C4F765C9AC3CB6B85D62379CE192D401AB61
uid           Bintray (by JFrog) <bintray@bintray.com>
sub   rsa4096 2015-02-17 [E]
$ sudo apt-key add Release-neofetch.key
$ rm Release-neofetch.key
$ #-- pkg情報更新&pkg導入
$ sudo apt update
$ sudo apt install neofetch

早速実行

$ neofetch --help

    NEOFETCH

    USAGE: neofetch --option "value" --option "value"

    NOTE: There's also a config option for each flag below.

    Info:
    --disable infoname          Allows you to disable an info line from appearing
                                in the output.
                                NOTE: You can supply multiple args. eg.
                                'neofetch --disable cpu gpu disk shell'
                                NOTE: The arguments must all be lowercase.
    --os_arch on/off            Hide/Show OS architecture.
    --speed_type type           Change the type of cpu speed to display.
                                Possible values: current, min, max, bios,
                                scaling_current, scaling_min, scaling_max
                                NOTE: This only support Linux with cpufreq.
    --cpu_shorthand type        Shorten the output of CPU
                                Possible values: name, speed, tiny, on, off
    --cpu_cores type            Whether or not to display the number of CPU cores
                                Takes: logical, physical, off
                                NOTE: 'physical' doesn't work on BSD.
    --cpu_speed on/off          Hide/Show cpu speed.
    --cpu_temp on/off           Hide/Show cpu temperature.
                                NOTE: This only works on Linux and BSD.
                                NOTE: For FreeBSD-based systems, you need to enable coretemp
                                      kernel module.
    --distro_shorthand on/off   Shorten the output of distro (tiny, on, off)
                                NOTE: This option won't work in Windows (Cygwin)
    --kernel_shorthand on/off   Shorten the output of kernel
                                NOTE: This option won't work in BSDs (except PacBSD and PC-BSD)
    --uptime_shorthand on/off   Shorten the output of uptime (tiny, on, off)
    --refresh_rate on/off       Whether to display the refresh rate of each monitor
                                Unsupported on Windows
    --gpu_brand on/off          Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel)
    --gtk_shorthand on/off      Shorten output of gtk theme/icons
    --gtk2 on/off               Enable/Disable gtk2 theme/icons output
    --gtk3 on/off               Enable/Disable gtk3 theme/icons output
    --shell_path on/off         Enable/Disable showing $SHELL path
    --shell_version on/off      Enable/Disable showing $SHELL version
    --ip_host url               Url to query for public IP
    --song_shorthand on/off     Print the Artist/Title on seperate lines
    --birthday_shorthand on/off Shorten the output of birthday
    --birthday_time on/off      Enable/Disable showing the time in birthday output
    --birthday_format format    Format the birthday output. (Uses 'date' cmd format)

    Text Formatting:
    --colors x x x x x x        Changes the text colors in this order:
                                title, @, underline, subtitle, colon, info
    --underline on/off          Enable/Disable the underline.
    --underline_char char       Character to use when underlining title
    --bold on/off               Enable/Disable bold text

    Color Blocks:
    --color_blocks on/off       Enable/Disable the color blocks
    --block_width num           Width of color blocks in spaces
    --block_height num          Height of color blocks in lines
    --block_range start end     Range of colors to print as blocks

    Bars:
    --bar_char 'elapsed char' 'total char'
                                Characters to use when drawing bars.
    --bar_border on/off         Whether or not to surround the bar with '[]'
    --bar_length num            Length in spaces to make the bars.
    --bar_colors num num        Colors to make the bar.
                                Set in this order: elapsed, total
    --cpu_display mode          Bar mode.
                                Takes: bar, infobar, barinfo, off
    --memory_display mode       Bar mode.
                                Takes: bar, infobar, barinfo, off
    --battery_display mode      Bar mode.
                                Takes: bar, infobar, barinfo, off
    --disk_display mode         Bar mode.
                                Takes: bar, infobar, barinfo, off

    Image:
    --image type                Image source. Where and what image we display.
                                Possible values: wall, ascii,
                                /path/to/img, /path/to/dir/, off
    --size 00px | --size 00%    How to size the image.
                                Possible values: auto, 00px, 00%, none
    --crop_mode mode            Which crop mode to use
                                Takes the values: normal, fit, fill
    --crop_offset value         Change the crop offset for normal mode.
                                Possible values: northwest, north, northeast,
                                west, center, east, southwest, south, southeast

    --xoffset px                How close the image will be to the left edge of the
                                window. This only works with w3m.
    --yoffset px                How close the image will be to the top edge of the
                                window. This only works with w3m.
    --bg_color color            Background color to display behind transparent image.
                                This only works with w3m.
    --gap num                   Gap between image and text.
                                NOTE: --gap can take a negative value which will
                                move the text closer to the left side.
    --clean                     Delete cached files and thumbnails.

    Ascii:
    --ascii value               Where to get the ascii from, Possible values:
                                distro, /path/to/ascii
    --ascii_colors x x x x x x  Colors to print the ascii art
    --ascii_distro distro       Which Distro's ascii art to print
                                NOTE: Arch and Ubuntu have 'old' logo varients.
                                NOTE: Use 'arch_old' or 'ubuntu_old' to use the old logos.
                                NOTE: Ubuntu has flavor varients.
                                NOTE: Change this to 'Lubuntu', 'Xubuntu', 'Ubuntu-GNOME'
                                or 'Ubuntu-Budgie' to use the flavors.
    --ascii_logo_size           Size of ascii logo.
                                Supported distros: Arch, Gentoo, Crux, OpenBSD.
    --ascii_bold on/off         Whether or not to bold the ascii logo.
    --logo | -L                 Hide the info text and only show the ascii logo.

    Screenshot:
    --scrot | -s /path/to/img   Take a screenshot, if path is left empty the screen-
                                shot function will use $scrot_dir and $scrot_name.
    --upload | -su /pth/t/img   Same as --scrot but uploads the scrot to a website.
    --image_host                Website to upload scrots to. Takes: imgur, teknik
    --scrot_cmd cmd             Screenshot program to launch

    Other:
    --config /path/to/config    Specify a path to a custom config file
    --config none               Launch the script without a config file
    --help                      Print this text and exit
    --version                   Show neofetch version
    -v                          Display error messages.
    -vv                         Display a verbose log for error reporting.

オプション結構多いです. とりあえず素で実行.

20161207_05:12:12-5188

情報もScreenfetchより増えています.

20161207_05:12:20-9093

次は画像を指定してみます.画像サイズが大きかったので25%に縮小もしています. 楽しい :)

20161207_05:12:35-3963

20161207_06:12:30-16979

画像の表示については環境によってうまく行く行かないがあるようです.うまく表示されない場合は以下のWikiを参照すると良さそうです.

マルチプラットホーム&スライドに特化したMarkdown WriterのMarpを試す

最近勉強会の発表資料はスライドにせずにMarkdownやAsciidocで書いてhtmlやpdfに書き出してました.これをSlideshareとかに置いているのですが,スライド形式に比べてアクセスが1桁少ないです. Markdownでスライドにする方法はいろいろあるのですが,1ページの分量がまちまちになってはみ出したりと言ったことをよくやってしまいあまりつかっていませんでした.

そんなところにプレゼンテーション向けのMarkdown Writerがあったので試してみました.

マルチプラットホームでElectron製です.PDFファイルへの書き出しも可能です.

雰囲気は以下の画像でだいたいわかるんじゃないかと思います.

https://yhatt.github.io/marp/images/marp-cast.gif

https://yhatt.github.io/marp/images/marp-cast.gif

左ペインでMarkdownを書いて右ページにプレビューが表示されます. プレビューは3種類選べますが,"1:1 slide/Slide List"のどちらかだとスライド形式でプレビューが表示されるのでレイアウトを確認しながら書くことができます.

試しにちょっと書いてみました. するとMarpのプレビュー,Evinceでは問題なかったのですが,SlideshareにPDFをアップロードすると背景画像やフッターが上下反転しています……. 試しにSpekerdeckにもアップロードしてみましたがこちらは問題なし. 恐らくSlideshareの問題ではないかと思います.

Electron製ということで降るmのマシンでは重いかなと思っていたのですが,Core2Duoのマシンでも試してみましたが一気にスクロールとかしなければ重く感じるところはなく実用範囲内に感じました.