Letting people know when you are asleep
While I have been trying to respond whenever people reach out to me, it is impossible to be available 24/7 due to the simple fact that a human has to sleep to be alive. While this is annoying, it is also a fact that I cannot change.
Therefore, a natural idea that comes to my mind is to simply let people know when I am asleep so that they do not expect me to respond immediately.
Discord and GitHub have been among my most used platforms for some time, and they both have a feature to let users set a custom status (with a custom text and an emoji). This opens up a possibility of using a program to automatically set the status to indicate that I am asleep.
For Discord, this is as simple as invoking a REST API (Notice that this is against Discord’s ToS):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
|
If you wonder what those base64-encoded strings mean, they are actually the binary contents of protobuf-encoded messages. See this .proto file for the definition of the message structure.
API v8
The commands written above was added when editing this article on July 20, 2025, which uses API v9. The latest API version as of originally writing this article was v8, but now using API v8 will get your account disabled, so do not use it!
1
2
3
4
5
6
7
8
9
10
11
12
13
|
|
For GitHub, there is not a REST API for that, but you can install the user-status plugin for GitHub CLI:
1
|
|
Then, you can set the status with:
1
2
3
4
5
|
|
Now, the next step is to run these commands automatically when I fall asleep and wake up. This can be done with MacroDroid, which can trigger actions based on various triggers. To run arbitrary commands, you can use the Tasker plugin for Termux. To have it working, one also needs to uncomment allow-external-apps = true in ~/.termux/termux.properties, and grant MacroDroid the permission to run Termux commands by
1
|
|
MacroDroid supports using the return value of the sleep API to trigger an action, but this tends to be quite unreliable on my device. Therefore, I use it in conjunction with a quick setting tile that I can toggle manually. The macro has two triggers:
- Fell Asleep / Woke Up (Android sleep API),
- Quick Tile On/Off,
and it has these actions:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
|
By the way, I have a bunch of topics that I want to write blog articles about, but I have been quite busy recently, so I may have to pause updating this blog for a while. I hope I can get back to writing soon!