/ Bitbar/SwiftBarを Linuxでも使いた い Kenichiro Matohara(matoken) <maroken@kagolug.org> CC BY-NC-SA 1 / 36 / $ apt --color moo moo 2>/dev/null | sed -e 's/Have you mooed today?/Happy MOO Year!/' 2 / 36 / 南隅から参加(鹿児島の右下) 好きなLinuxディストリビューションはDebian お仕事募集 mailto:work@matohara.org Kenichiro Matohara(matoken) https://matoken.org 3 / 36 / 最近の発表 「 」 2020-12-26 「 」 2021-01-09 誰でもファイルアップロード 鹿児島Linux勉強会 2020.12(オン ライン開催) VeraCryptをzuluCryptで 小江戸らぐ 1月のオフな集まり(第222 回) 4 / 36 / 鹿児島らぐ 次回 2021-01-31(sun) オープンソースカンファレンス2021 Springにも参加予定 鹿児島Linux勉強会 2021.01(オンライン開催) 5 / 36 / BitBar/SwiftBar PodcastのRebuild.fm 292回でBitBar, SwiftBar というツールバーに任意 のコマンドの結果を表示できるツールを知る macOS用 Linuxで動くものがないか探してみる Rebuild: 292: Two Chickens, One Stone (hak) GitHub - matryer/bitbar: Put the output from any script or program in your Mac OS X Menu Bar SwiftBar https://nitter.net/matoken1/status/1344632867100364801 6 / 36 / BitBar/SwiftBar Alternative 現環境はAwesome wmなのでどれも動かなさそう(◞‸◟) GitHub - p-e-w/argos: Create GNOME Shell extensions in seconds GitHub - lipido/kargos: KDE Plasma port of GNOME Argos and OSX BitBar GitHub - ssimono/margos: Create Mate applets from your script output 7 / 36 / Margosを試す とりあえず一番導入が楽そうなMateを導入してMargosを試す MargosにはMate 1.18以上,gtk-3,Python 3.6以上,pipが必要 8 / 36 / margos導入 1 pipコマンドでmargosを導入 2 デスクトップ環境で利用できるようにする 3 mate-panelを再起動する $ sudo pip3 install -U margos $ sudo margos install $ killall mate-panel 1 2 3 9 / 36 / margosアプレット登録 パネルにアプレットを登録して任意のコマンドを登録 パネルで右クリックしてアプレットの追加 アプレット内の「コマンド」を選択して追加 10 / 36 / いくつかの問題 11 / 36 / エスケープシーケンスがそのま ま出力される colorなどは使わないようにしましょう. wego -d 1 -f emoji | head -4 | tail -1 12 / 36 / 日本語や記号の問題 ⚡21時/84% と表示したいところの 時 部分が ? になり, % が消え てしまった 絵文字がOKで日本語がNGなパターンは初めて見た気がする タイミングによりうまく動かないのに気づいた>< echo -n ⚡$((`date +%H`-1))時/; \ curl -s https://www.kyuden.co.jp/td_power_usages/csv/juyo-hourly-`date +%Y%m%d`.csv | \ head -38 | tail -24 | grep ,$(( `date +%H` -1 )):00 | cut -z -d, -f5;echo % 13 / 36 / パイプ等を使うと動かない | でつないだりするとうまく動かない sh -c "command1 | command2" のようにsh経由で動かすとOK ファイルに書き出してそれを指定したほうがいい? 14 / 36 / Margosまとめ MargosはBitBarに比べると機能が少ない watchコマンドをMateパネルに置く感じ 15 / 36 / Argosを試す Margosの機能が少ないのでGnome Shell環境を用意してArgosを試す Gnome shellの拡張機能として提供されている BitBarコンパチ! p-e-w/argos: Create GNOME Shell extensions in seconds 16 / 36 / Argos導入 ブラウザから導入もしくは手動でダウンロードして展開 ダウンロード時はGnome shellのバージョンを求められる Gnome Shellバージョン確認 手動での導入 Alt+F2 r↲ でGnome Shellを再起動して反映 Argos - GNOME Shell 拡張機能 $ gnome-shell --version GNOME Shell 3.38.3 $ mkdir -p ~/.local/share/gnome-shell/extensions $ unzip ./argospew.worldwidemann.com.v3.shell-extension.zip \ -d ~/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/ 17 / 36 / Gnome Shellが新しいとうまく動 かない ステータスバーには現れるがクリックしてもウィンドウが開かな い Gnome Shellが新しいとこうなるらしい(3.36+?今回は3.38.3) Gitリポジトリのmasterと以下のPRのpatchを利用して動作 Argos menus won’t open on Ubuntu 20.04 - Is it a known issue? · Issue #120 · p-e-w/argos · GitHub Use registerClass to make plugin compatible with gnome 3.36. by rammie · Pull Request #111 · p-e-w/argos · GitHub 18 / 36 / 導入し直し Gnome Shell 3.36+の場合のみ 19 / 36 / 旧バージョンを削除 1 無効化 2 アンインストール $ gnome-extensions disable argos@pew.worldwidemann.com $ gnome-extensions uninstall argos@pew.worldwidemann.com 1 2 20 / 36 / GitのmasterとPR適用 1 リポジトリclone 2 拡張機能コピー 3 Gnome Shell 3.36+向けの修正を適用 Alt+F2 r↲ でGnome Shellを再起動して反映 $ git clone github.com/p-e-w/argos $ cd argos $ cp -p ./argos@pew.worldwidemann.com \ ~/.local/share/gnome-shell/extensions/ $ wget https://raw.githubusercontent.com/p-e-w/argos/c4663d9d3e29ef33b7e9123ef0c09581 -O ~/.local/share/gnome-shell/extensions/argos@pew.worldwidemann.com/menuitem.js 1 2 3 21 / 36 / Argosデフォルトプラグイン確認 ステータスバーにArgosが現れる クリックでウィンドウが表示される 最下部の argos.sh をクリックするとテキストエディタで開かれ る 22 / 36 / Argos.sh #!/usr/bin/env bash URL="github.com/p-e-w/argos" DIR=$(dirname "$0") echo "Argos" echo "---" echo "$URL | iconName=help-faq-symbolic href='https://$URL'" echo "$DIR | iconName=folder-symbolic href='file://$DIR'" 23 / 36 / Argos Plugin ~/.config/argos/ に実行可能プラグラムやスクリプトを置くと 即実行される STDOUT出力結果1行目がバーに表示され,--- の後がウィンドウ 内に表示される インターバルはファイル名で制御 hoge.3s+.sh #3秒毎に実行 fuga.10m+.py #10分毎に実行 色を付けたりアイコンを設定したり…… 24 / 36 / wegoで天気表示 天気をバーに表示してクリックすると2日分の天気予報を表示(罫線が 崩れている) 25 / 36 / ~/.config/argos/wego.1h+.sh #!/bin/bash STR=`wego -d 2 -f emoji` echo "`echo "${STR}" | head -4 | tail -1`" echo "---" echo "${STR}" | awk 1 ORS="\\\\n" echo " | font=monospace" 26 / 36 / CPUの温度とtop表示 1分毎にCPUの温度をバーに表示して,クリックするとtopコマンドを 表示 27 / 36 / ~/.config/argos/cputhermal.1m+.sh ※色が変更できない? #!/bin/bash THERMAL=`acpi -t | awk '{print $4}'` COLOR="white" if [ `echo "${THERMAL} >= 80" | bc` == 1 ] ; then COLOR="red" fi #echo "<span color='${COLOR}' weight='normal'><tt>