Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CLIでWebカレン ダー(WebDAV)を 表示したい

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

CLIでWebカレン ダー(WebDAV)を 表示したい

Avatar for Kenichiro MATOHARA

Kenichiro MATOHARA

May 01, 2021
Tweet

More Decks by Kenichiro MATOHARA

Other Decks in Technology

Transcript

  1. ~/.config/vdirsyncer/config [general] status_path = "~/.vdirsyncer/status/" [pair my_calendars] a = "my_calendars_local"

    b = "my_calendars_remote" collections = null metadata = ["color"] [storage my_calendars_local] type = "filesystem" path = "~/.calendars/" fileext = ".ics" [storage my_calendars_remote] type = "caldav" url = "https://files.matoken.org/remote.php/dav/public-calendars/YW5gc6gMG8tC63AH?export" 10 / 26
  2. カレンダー同期 カレンダー同期 1 初回のみ 2 同期実行 $ vdirsyncer discover my_calendars

    Discovering collections for pair my_calendars my_calendars_local: my_calendars_remote: - "YW5gc6gMG8tC63AH" ("onlin_event (matoken)") warning: No collection "YW5gc6gMG8tC63AH" found for storage my_calendars_local. Should vdirsyncer attempt to create it? [y/N]: y Saved for my_calendars: collections = ["YW5gc6gMG8tC63AH"] $ vdirsyncer sync Syncing my_calendars/YW5gc6gMG8tC63AH Copying (uploading) item 05f764a4-8c30-46ed-a0fe-62c67d3975a8 to my_calendars_local/YW5gc6gMG8 Copying (uploading) item 1acc3691-a12b-4534-a4e2-6ee6213ecff1 to my_calendars_local/YW5gc6gMG8 Copying (uploading) item 202e727b-0431-40b5-8008-9ada1269c7c8 to my_calendars_local/YW5gc6gMG8 Copying (uploading) item 2312a403-b2e6-4716-9c6f-45aa94519654 to my_calendars_local/YW5gc6gMG8 : 1 2 11 / 26
  3. ~/.config/khal/config 1 .ical のパスを指定 [calendars] [[event]] path = ~/.calendars/YW5gc6gMG8tC63AH/ readonly

    = True [locale] timeformat = %H:%M dateformat = %Y-%m-%d longdateformat = %Y-%m-%d datetimeformat = %Y-%m-%d %H:%M longdatetimeformat = %Y-%m-%d %H:%M 1 14 / 26
  4. exmple exmple 1 今日から今日まで表示 2 今日から7日間表示 3 03/01〜03/31まで表示 4 LC_TIMEでローカライズ(曜日など)

    5 faketimeで05/03としてkhalを実行 $ khal list --format "{title}" today today $ khal list --format "{title}" today 7days $ khal list --format "{title}" 2021-05-01 2021-05-31 $ LC_TIME=ja_JP.UTF-8 khal list --format "{title}" 2021-05-01 2021-05-31 $ faketime 2021-05-03 khal list --format "{title}" today 1 2 3 4 5 18 / 26
  5. 目的の1月分くらいのカレンダ 目的の1月分くらいのカレンダ ーを出力 ーを出力 $ LC_TIME=ja_JP.UTF-8 khal list --format "{title}"

    today 31days Tomorrow, 2021-05-01 LILO&東海道らぐオンラインミーティング 2021-05-01 月曜日, 2021-05-03 憲法記念日 火曜日, 2021-05-04 みどりの日 水曜日, 2021-05-05 こどもの日 土曜日, 2021-05-08 TLUG technical meeting(online) 小江戸らぐ 5月のオフな集まり(第226回) 金曜日, 2021-05-14 第74回FreeBSDワークショップ(オンライン) 土曜日, 2021-05-15 東京エリア・関西合同 Debian 勉強会 (予定) 低レベル勉強会2021年05月 日曜日, 2021-05-16 秋葉原ロボット部 2021年5月 第104回勉強会 月曜日, 2021-05-17 OSC2021 Online/Hokkaido 申込締切 木曜日, 2021-05-20 第87回FreeBSD勉強会 日曜日, 2021-05-23 鹿児島Linux勉強会 2021.05(TBD) 土曜日, 2021-05-29 Open Source Conference 2021 Online Nagoya 日曜日, 2021-05-30 ディストリビューション開発もくもく会 2021年5月 19 / 26
  6. curlで投稿テスト curlで投稿テスト $ curl -X POST -H "Content-Type: application/json" \

    -d '{"username": "ボット", "content": "こんにちは 🤖 "}' \ 'https://ptb.discord.com/api/webhooks/826777625053495306/QZoG2LLZOFlsKO_Auf1IQcXHVFozlgU37EGO 21 / 26
  7. 今日のカレンダー投稿script 今日のカレンダー投稿script $ cat /home/matoken/bin/calpost.sh #!/bin/sh # khal # list

    -> 一覧表示 # --format "{title}" -> タイトルだけ表示 # today -> 今日から # today -> 今日まで # sed -> jsonの改行形式に変換 CAL=$(khal list --format "{title}" today today | grep -v ^Today,\ | sed -z -e "s/\n/\\\\r/g") echo "${CAL}" # イベントのない日は投稿せず終了 if [ "${CAL}" = 'No events\r' ] then echo "${CAL}" exit fi # https://qiita.com/Eai/items/1165d08dce9f183eac74 MSG=$(printf '{"username": "今日のイベント 📅 ", "content": "%s"}' "${CAL}") echo "$MSG" # Discord WebHock でKagolug の#random へpost curl -X POST -H "Content-Type: application/json" \ -d "${MSG}" \ 'https://ptb.discord.com/api/webhooks/826777625053495306/QZoG2LLZOFlsKO_Auf1IQcXHVFozlg 22 / 26
  8. crontabに登録して毎日投稿 crontabに登録して毎日投稿 $ crontab -l | grep calpost 58 4

    * * * /home/matoken/bin/calpost.sh 2>&1 > /home/matoken/tmp/cron/calpost.sh.log 23 / 26
  9. 奥付 奥付 発表 発表者 公開URL , , 利用ソフトウェア ライセンス CC

    BY-NC-SA 4.0 LILO&東海道らぐオンラインミーティング 2021-05-01 Kenichiro Matohara(matoken) SpeakerDeck pdf pdf-sig source Asciidoctor Reveal.js 26 / 26