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

Raspberry Pi Zero Tips

ダウンロード
Raspberry-Pi-Zero-web
24日にKSYとスイッチサイエンスからRaspberry Pi Zero発売ってことでTipsを書いてみます.

Raspberry-Pi-Zero-web (コピー)

  • 本体の他に最低限microSD(OS領域)やmicroUSBケーブル(電源)が必要です.(microUSBへのOS導入に別途PCも必要).
  • HDMIディスプレイを利用したい場合は大抵の場合別途mini HDMIからフルサイズへの変換アダプタやケーブルが必要です.※PIZEROはmini HDMIです.よく見かけるのはmicro HDMIなので注意しましょう.
  • コンポジットのディスプレイを利用したい場合はジャックなどをはんだ付けする必要があります.(TVのシルク)
  • microUSBx2のうち片方(PWR IN)は電源専用です.
  • もう片方(USB)はUSB OTGでHOSTにもGadget(SerialやEthernetはdebugに便利!)にもなれます.電源供給も可能なので電源容量が足りるならこの1本だけで運用することも可能です.microUSBケーブルやOTGケーブルはそれなりのものを使ったほうが良いです.安いものを使ったらPIZERO側のコネクタが傷んで使えなくなってしまいました.
  • USBを利用する場合は給電が可能なmicroUSBのHUBがデバッグに便利です.
  • GPIO Pinは+以降と共通だけどピンは未実装なので利用したい場合は自分で別途ピンヘッダ等購入してはんだ付けする必要があります.カラフルなピンヘッダをASUS TINKER BOARDのようにピンの用途毎に変えると便利そうです.
    XxbHbzYFnf4AVH1a_setting_fff_1_90_end_1000C-06641

  • 純正カメラモジュールを利用する場合はRaspberry Pi Zero V1.3以降が必要(KSYもスイッチサイエンスもV1.3と書かれているので問題ない)で更にカメラモジュール付属のものとは別のPIZERO専用のケーブルが必要です.

  • KSYでは5000円以上送料無料,それ以下は一律756円の送料が掛かる.KSYを初めて使う人は形式チェックが厳しくて結構面倒なので前もってアカウントを登録しておいたほうが良いです.(単品で買うのであれば海外で買うのと変わらないか高いくらいなので早く欲しい人向け?)
  • スイッチサイエンスでは送料150円.3000円以上送料無料.単品で買う場合おすすめ.但し2017年3月20日週から順次発送予定なので届くまで暫くかかります.
  • 余録.チョコベビーの容器はケースにちょうどいいです :)
    • IMG_20170216_075638

Raspberry Piでコンポジットで起動した後に解像度やディスプレイを変更する

コンポジット出力の解像度変更

Raspberry Piを起動するときにHDMIを接続した状態で起動すると高解像度で起動しますが,繋いでいないとコンポジット出力で起動してXの解像度が720×480になってちょっと手狭です.
xrandrで解像度を追加するとXの再起動もせずに高解像度に出来ます.

※xrandrコマンドは対象のX端末上か,DISPLAY変数を対象のものを指定して実行すること

  • 720x480しか選べない
$ xrandr 
Screen 0: minimum 320 x 200, current 720 x 480, maximum 2048 x 2048
HDMI-0 disconnected (normal left inverted right x axis y axis)
Composite-0 unknown connection 720x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   720x480       62.69* 
DSI-0 disconnected (normal left inverted right x axis y axis)
  • cvtコマンドで設定したい解像度を指定してModelineを調べる
$ cvt 1360 768
# 1360x768 59.80 Hz (CVT) hsync: 47.72 kHz; pclk: 84.75 MHz
Modeline "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync
  • xrandrのmodeを作成する
$ xrandr --newmode "1360x768_60.00"   84.75  1360 1432 1568 1776  768 771 781 798 -hsync +vsync
  • modeが増えている
$ xrandr 
Screen 0: minimum 320 x 200, current 720 x 480, maximum 2048 x 2048
HDMI-0 disconnected (normal left inverted right x axis y axis)
Composite-0 unknown connection 720x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   720x480       62.69* 
DSI-0 disconnected (normal left inverted right x axis y axis)
  1360x768_60.00 (0x248) 84.750MHz
        h: width  1360 start 1432 end 1568 total 1776 skew    0 clock  47.72KHz
        v: height  768 start  771 end  781 total  798           clock  59.80Hz
  • modeをComposite-0に追加する
$ xrandr --addmode Composite-0 1368x768_60.00
$ xrandr 
Screen 0: minimum 320 x 200, current 720 x 480, maximum 2048 x 2048
HDMI-0 disconnected (normal left inverted right x axis y axis)
Composite-0 unknown connection 720x480+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   720x480       62.69* 
   1360x768_60.00  59.80  
DSI-0 disconnected (normal left inverted right x axis y axis)
  • 設定したmodeに切り替える
$ xrandr --output Composite-0 --mode 1360x768_60.00

起動後にHDMIに切り替える

解像度の変更ではなく起動後にHDMI接続に切り替えるのもxrandrで出来ます.こちらもXの再起動は必要ありません.

  • HDMIケーブルを接続するとHDMI-0 connectedとなってmodeが選べるようになる
$ xrandr 
Screen 0: minimum 320 x 200, current 1366 x 768, maximum 2048 x 2048
HDMI-0 connected 1366x768+0+0 (normal left inverted right x axis y axis) 580mm x 360mm
   1366x768      59.79*+
   1920x1080     60.00    59.94  
   1920x1080i    60.00    50.00    59.94  
   1280x1024     60.02  
   1152x864      75.00  
   1280x720      60.00    58.68    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x576i      50.00  
   720x480       60.00    59.94  
   720x480i      60.00    59.94  
   640x480       75.00    72.81    66.67    60.00    59.94  
   720x400       70.08  
Composite-0 unknown connection (normal left inverted right x axis y axis)
   720x480       62.69  
   1360x768_60.00  59.80  
DSI-0 disconnected (normal left inverted right x axis y axis)
  • 一度にコンポジットを無効にしてHDMIを有効にしようとするとエラーとなる
$ xrandr --output Composite-0 --off --output HDMI-0 --auto
xrandr: cannot find crtc for output HDMI-0
  • 一度に行うのではなく先にコンポジットを無効にしてからHDMIを有効にするとうまく行った
$ DISPLAY=:0 xrandr --output Composite-0 --off
$ DISPLAY=:0 xrandr --output HDMI-0 --auto
  • 逆にHDMIからコンポジットに切り替えることも出来る
$ xrandr --output HDMI-0 --off
$ xrandr --output Composite-0 --mode 1360x768_60.00

環境

  • HW : Raspberry Pi B 2
$ screenfetch 
    .',;:cc;,'.    .,;::c:,,.    pi@raspberrypi
   ,ooolcloooo:  'oooooccloo:    OS: Unknown 8.0 jessie
   .looooc;;:ol  :oc;;:ooooo'    Kernel: armv7l Linux 4.9.11-v7+
     ;oooooo:      ,ooooooc.     Uptime: 4h 28m
       .,:;'.       .;:;'.       Packages: 1541
       .... ..'''''. ....        Shell: 3362
     .''.   ..'''''.  ..''.      Resolution: 1368x768
     ..  .....    .....  ..      DE: LXDE lxpanel 0.7.2
    .  .'''''''  .''''''.  .     WM: OpenBox
  .'' .''''''''  .'''''''. ''.   GTK Theme: Clearlooks [GTK2], Not Found [GTK3]
  '''  '''''''    .''''''  '''   Icon Theme: nuoveXT2
  .'    ........... ...    .'.   Font: Sans 10
    ....    ''''''''.   .''.     CPU: ARMv7 rev 5 (v7l) @ 900MHz
    '''''.  ''''''''. .'''''     RAM: 258MB / 922MB
     '''''.  .'''''. .'''''.    
      ..''.     .    .''..      
            .'''''''            
             ......       

mpv audio delay

動画プレイヤーのmpvを最近良く使うけどBluetoothで音が遅れるのでディレイ掛けたい.
vlcだとj,kというショートカットで50msずつずらせたので同じようなことがしたい.
man見ると載っててmpvだとCtrl + / Ctrl -みたい,だけど100ms単位.
コマンドラインオプションや設定ファイルだと細かく指定できた.

  • ショートカット
       Ctrl + and Ctrl -
              Adjust audio delay by +/- 0.1 seconds.

※100ms単位(VLCは50ms単位)

  • オプション
       --audio-delay=<sec>
              Audio delay in seconds (positive or negative float value). Positive values delay the audio, and negative values delay the video.

こちらは細かい時間を指定可能.以下は-250msを指定.
$ mpv --audio-delay=-0.25 FILE
この状態でショートカットを利用すると-250ms -> -150msのような感じに100ms単位で移動する.

  • 設定ファイル
$ cat ~/.config/mpv/mpv.conf
audio-delay=-0.25
  • 環境
$ 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 mpv
mpv     0.23.0-2

引用はmpv(1)より

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を登録で行けそう?

マイク

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

鹿児島Linux勉強会 2017.01に参加

今回は遠隔参加を試してみました.BigBluebuttonなどの会議システムは映像も双方向に送れていい感じなのですが,野良勉強会では回線が無かったり今使っているPCではリアルタイムエンコードが難しいという問題があります.そこで音声のみのMumbleを利用しました.

サーバはさくらのVPSに設定,会場ではBluetoothマイク兼スピーカーで……と思ったのですが,このマイクではうまく音を拾わない&ヘッドホンのプロファイルでは音質も悪いのでA2DPにしてスピーカーのみの利用として,マイクはPC直付にしました.
このマイクは一応前指向性ですが数百円の安物なので音質は悪かったと思います.
でも双方向でのやり取りが出来るのは良かったです.会議室利用の際は良さそうです.

今回は資料が事前に共有できていたので良かったですが,資料が事前に共有できない場合はやはりどうにか映像を共有する方法を考えないといけないでしょうね.
そうするとやはりBBBやYoutubeLive等が必要に…….(帯域をなるべく絞って映像のみRaspberry PiでYoutubeLive配信というのが現実的かな?)

私の発表した内容は以下の3本でした.

Raspberry PiのUSB OTGを試す // Speaker Deck

USBを保護するUSBGuard // Speaker Deck

ゲーミングプラットホームのLutris紹介 // Speaker Deck

データはこちら.
matoken / 鹿児島Linux勉強会2017.01 / ソース / — Bitbucket

Raspberry PiのUSB OTGはさわりだけでちょっとあれでした.次回までにもうちょっと…….

次回は2月上旬の土日にと思っています.今年は月一ペース開催を目標にと思っています.
最近は開催場所どうしよう……となって日が過ぎていくパターンなのでとりあえず日程アナウンスはして会場見つからなかったらマクドナルドとかで開催という感じで考えています.

コマンドスニペットを手軽に調べられるコマンドの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を参照すると良さそうです.