blob: 94e9b33ee90cbae049c322676ec6b5b1548b5f43 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# chzzkd
Stream notification daemon for <https://chzzk.naver.com>. It executes
shell hooks (by `/bin/sh -c`) when listed channels go live or
offline. Useful context, such as the stream title, is passed to the
script as environment variables.
Example configuration:
```toml
timeout = 10
[hooks]
went_open = '''
url="https://chzzk.naver.com/live/$CHZZKD_ID"
action=$(notify-send -a chzzkd \
-A default="mpv" \
"$CHZZKD_ALIAS: hello" \
"$CHZZKD_LIVE_TITLE")
case "$action" in
default) mpv "$url" ;;
esac
'''
went_close = 'notify-send -a chzzkd "$CHZZKD_ALIAS: bye"'
[[channel]]
id = "c847a58a1599988f6154446c75366523"
alias = "dopa"
[[channel]]
id = "a7e175625fdea5a7d98428302b7aa57f"
alias = "chamcham"
[[channel]]
id = "6e06f5e1907f17eff543abd06cb62891"
alias = "nokduro"
[[channel]]
id = "c100f81959d1c17044be0541eed56f5b"
alias = "megajw"
[[channel]]
id = "8b3e8e3a13201cff0836c69cfab62f45"
alias = "flame"
[[channel]]
id = "732f6f16d20991243ec3f2d7afed8821"
alias = "0du"
```
This polls each channel every 10 seconds. When a stream goes live
(`went_open`), it sends a clickable desktop notification. Clicking it
opens the stream directly in `mpv`. When a stream goes offline
(`went_close`), it says goodbye and leaves.
Also, you may find it useful that
```sh
chromium --app="https://chzzk.naver.com/live/$CHZZKD_ID/chat"
```
opens the popup chat window for the channel. :)
---
How to install and run:
```sh
git clone https://github.com/dilluti0n/chzzkd
cd chzzkd
cargo install --path .
mkdir -p "$HOME/.config/chzzkd/"
cp example_config.toml "$HOME/.config/chzzkd/config.toml"
chzzkd
# Run as daemon
RUST_LOG=info setsid chzzkd 2>chzzkd.log >/dev/null
# Reload configuration
pkill -HUP chzzkd
# Stop daemon
pkill chzzkd
```
Synopsis: `chzzkd [CONFIG]`
Configuration path precedence:
1. `CONFIG` (command line argument)
2. $XDG_CONFIG_HOME/chzzkd/config.toml
3. $HOME/.config/chzzkd/config.toml
4. /etc/chzzkd/config.toml
|