mirror of
https://github.com/bvanroll/_dotfiles.git
synced 2025-08-29 20:12:42 +00:00
init
This commit is contained in:
22
.config/i3blocks/github/README.md
Normal file
22
.config/i3blocks/github/README.md
Normal file
@@ -0,0 +1,22 @@
|
||||
# Github
|
||||
|
||||
Shows Github notifications and adds a shortcut to access your notifications. It uses [Github's CLI](https://github.com/cli/cli) for api interactions and for an API access.
|
||||
|
||||
# Dependencies
|
||||
|
||||
- [gh-cli](https://github.com/cli/cli)
|
||||
- [Font Awesome](https://fontawesome.com) for the Github icon.
|
||||
|
||||
# Usage
|
||||
|
||||
Clicking the Github icon will open Github's notifications panel.
|
||||
|
||||
# Config
|
||||
|
||||
```ini
|
||||
[github]
|
||||
command=$SCRIPT_DIR/github/github
|
||||
interval=60
|
||||
format=json
|
||||
markup=pango
|
||||
```
|
35
.config/i3blocks/github/github
Executable file
35
.config/i3blocks/github/github
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
A Github block for displaying notifications in i3 using i3blocks
|
||||
"""
|
||||
|
||||
__author__ = "Adin Hodovic <hodovicadin@gmail.com>"
|
||||
__copyright__ = "Copyright (c) 2020 Adin Hodovic"
|
||||
__license__ = "MIT"
|
||||
__version__ = "1.0.0"
|
||||
|
||||
import json
|
||||
import os
|
||||
import webbrowser
|
||||
|
||||
|
||||
def get_notifications():
|
||||
notifications = len(json.loads(os.popen("gh api notifications").read()))
|
||||
|
||||
if notifications > 0:
|
||||
return {
|
||||
"full_text": f"<span font='Font Awesome 5 Free Solid'> {notifications}</span>"
|
||||
}
|
||||
return {"full_text": "<span font='Font Awesome 5 Free Solid'></span>"}
|
||||
|
||||
|
||||
def clicked():
|
||||
"""Returns True if the button was clicked"""
|
||||
button = "BLOCK_BUTTON" in os.environ and os.environ["BLOCK_BUTTON"]
|
||||
return bool(button)
|
||||
|
||||
|
||||
if clicked():
|
||||
webbrowser.open("https://github.com/notifications")
|
||||
|
||||
print(json.dumps(get_notifications()))
|
5
.config/i3blocks/github/i3blocks.conf
Normal file
5
.config/i3blocks/github/i3blocks.conf
Normal file
@@ -0,0 +1,5 @@
|
||||
[github]
|
||||
command=$SCRIPT_DIR/github/github
|
||||
interval=60
|
||||
format=json
|
||||
markup=pango
|
Reference in New Issue
Block a user