[script] Add simple due script for bibtex file

Scrapes a bibtex file for 'due' field, and outputs all found entries
with their priority and sorted for date.
This commit is contained in:
Marty Oehme 2020-05-16 17:05:09 +00:00
parent 1f25f86290
commit f96f9f2211
24 changed files with 455 additions and 27 deletions

View file

@ -17,10 +17,8 @@
;==========================================================
[colors]
;background = ${xrdb:color0:#222}
background = ${xrdb:background}
background-alt = ${xrdb:color8}
;foreground = ${xrdb:color7:#222}
foreground = ${xrdb:foreground}
foreground-alt = ${xrdb:color3}
primary = ${xrdb:color1}
@ -46,6 +44,10 @@ margin-top = 0
margin-bottom = 0
[bar/simple-top]
; enable inter process communication, so that we can send messages
; to polybar via polybar-msg command
enable-ipc = true
; Put the bar at the bottom of the screen
bottom=false
@ -56,7 +58,7 @@ padding-right = 0
module-margin-left = 2
modules-left = workspaces
modules-center = mprisdisplay date
modules-center = music date papersdue
modules-right = networkspeed archupdates cpu temp backlight volume battery
; do not use offsets for the bar, would only work with override-redirect
; and will mess up tray https://github.com/polybar/polybar/issues/1355
@ -85,7 +87,7 @@ fixed-center = true
; See the Fonts wiki page for more details
font-0 = Comic Neue
font-1 = NotoSans
font-2 = Iosevka:size=18
font-2 = Iosevka:size=18;1
cursor-click = pointer
@ -177,12 +179,12 @@ interval = 1.0
; To list all the zone types, run
; $ for i in /sys/class/thermal/thermal_zone*; do echo "$i: $(<$i/type)"; done
; Default: 0
thermal-zone = 0
thermal-zone = 2
; Use `sensors` to find preferred temperature source, then run
; $ for i in /sys/class/hwmon/hwmon*/temp*_input; do echo "$(<$(dirname $i)/name): $(cat ${i%_*}_label 2>/dev/null || echo $(basename ${i%_*})) $(readlink -f $i)"; done
; hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon0/temp1_input
; Base temperature for where to start the ramp (in degrees celsius)
base-temperature = 40
base-temperature = 50
; Threshold temperature to display warning label (in degrees celsius)
warn-temperature = 70
units = true
@ -209,26 +211,44 @@ date-alt = %A, %d %B %Y (W %V)
time-alt = %H:%M
label = %date% %{T2} %{T-}%time%
; display information on currently playing track, allows simple track manipulation
[module/music]
type = custom/script
exec = $XDG_CONFIG_HOME/polybar/scripts/poly-mprisdisplay
exec-if = type $XDG_CONFIG_HOME/polybar/scripts/poly-mprisdisplay
tail = true
click-left = kill -USR1 %pid%
click-right = kill -USR2 %pid%
; TODO: add album art display (on click?) - retrieved by playerctl metadata mpris:artUrl
; display information on remaining papers to read for the upcoming week
[module/papersdue]
type = custom/script
exec = $XDG_CONFIG_HOME/polybar/scripts/poly-papersdue
exec-if = type bib-due
tail = true
click-left = exist rofi-bib-due normal "opening due papers" && rofi-bib-due -p1 -u $(date --date='fri this week' +%Y-%m-%d)
; format-foreground = ${colors.primary}
format-prefix = " "
interval = 120
; display unified available packages for update on arch from repos/aur
; uses pacman-contrib/checkupdates if available to avoid partial arch upgrades
[module/archupdates]
type = custom/script
exec = $XDG_CONFIG_HOME/polybar/scripts/poly-archupdates
exec-if = type $XDG_CONFIG_HOME/polybar/scripts/poly-archupdates
interval = 600
format = <label>
format-foreground = ${colors.primary}
label = %output%
format-padding = 2
format-prefix = " "
; format-foreground = ${colors.primary}
[module/networkspeed]
type = custom/script
exec = $XDG_CONFIG_HOME/polybar/scripts/poly-networkspeed
tail = true
[module/mprisdisplay]
type = custom/script
exec = $XDG_CONFIG_HOME/polybar/scripts/poly-mprisdisplay
interval = 3
click-left = playerctl play-pause &
; TODO: add album art display (on click?) - retrieved by playerctl metadata mpris:artUrl
[module/volume]
type = internal/pulseaudio
; Available tags:

View file

@ -5,7 +5,7 @@
# returns empty string when 0 packages are available, so
# that polybar simply displays nothing.
#
# dependendies: yay, bc, (pacman-contrib optional)
# dependendies: yay, (pacman-contrib optional)
# prefer checkupdates since it allows checking w/o partial upgrade
if command -v "checkupdates" >/dev/null; then
@ -21,7 +21,7 @@ updates_aur="$(yay -Qum 2>/dev/null | wc -l)"
# if ! updates_aur=$(pikaur -Qua 2> /dev/null | wc -l); then
# if ! updates_aur=$(rua upgrade --printonly 2> /dev/null | wc -l); then
updates="$(echo "$updates_repo + $updates_aur" | bc)"
updates="$((updates_repo + updates_aur))"
if [ "$updates" -gt 0 ]; then
echo "$updates"

View file

@ -1,11 +1,47 @@
#!/bin/sh
# script to echo the current playback situation
#
# call without args to return playing symbol or empty, depending on current playback status
# call with 1 to return 'artist - title' metadata (verbose mode)
# send SIGUSR2 signal to toggle pause/playing state of song (e.g. kill -USR2 %PID)
#
# depends on playerctl being installed
player_status=$(playerctl status 2>/dev/null)
exist playerctl low "polybar music" || exit 1
if [ "$player_status" = "Playing" ]; then
echo "ﱘ $(playerctl metadata artist) - $(playerctl metadata title)"
elif [ "$player_status" = "Paused" ]; then
echo " $(playerctl metadata artist) - $(playerctl metadata title)"
else
echo ""
fi
mode=${1:-0}
update_time=1
symbol_playing=""
symbol_paused=""
modetoggle() {
mode=$(((mode + 1) % 2))
}
trap "modetoggle" USR1
playpause() {
playerctl play-pause
}
trap "playpause" USR2
decorate() {
if [ "$player_status" = "Playing" ]; then
echo "${symbol_playing}$1"
elif [ "$player_status" = "Paused" ]; then
echo "${symbol_paused}$1"
else
echo ""
fi
}
while true; do
player_status=$(playerctl status 2>/dev/null)
if [ $mode -eq 0 ]; then
decorate ""
elif [ $mode -eq 1 ]; then
decorate " $(playerctl metadata artist) - $(playerctl metadata title)"
fi
sleep $update_time &
wait
done

View file

@ -0,0 +1,15 @@
#!/usr/bin/env sh
while true; do
all="$(bib-due -u "$(date --date='fri this week' +%Y-%m-%d)" | wc -l)"
required="$(bib-due -u "$(date --date='fri this week' +%Y-%m-%d)" -p1 | wc -l)"
# add polybar formatting to color required readings red
# https://github.com/polybar/polybar/wiki/Formatting#format-tags
# TODO use xresources
colorreq=$(xrdb -query | grep -e '\*color1:' | cut -f2)
colorall=$(xrdb -query | grep -e '\*foreground:' | cut -f2)
printf "%s%s%s(%s)\n" "%{F${colorall:-#000}}" "$all" "%{F${colorreq:-#d00}}" "$required"
sleep 120
done

View file

@ -1,4 +1,6 @@
#!/usr/bin/env bash
# force start or restart (all) polybar instances
# if ipc is enabled, can be replaced with `polybar-msg cmd restart`, provided polybar is not stuck
# Terminate already running bar instances
killall -q polybar

85
polybar/README.md Normal file
View file

@ -0,0 +1,85 @@
# Polybar module
[polybar](https://polybar.github.io/) - a fast and easy-to-use statusbar
[[_TOC_]]
## Polybar look
minimal look:
![minimal](.assets/polybar/minimal.png)
Active i3 workspaces are displayed left with current workspace highlighted, and any active i3 modes. The center contains information on the currently playing song, displaying notes if something is playing, date and time, and upcoming bib readings from the library. The right contains system information and the task tray.
with network activity:
![network](.assets/polybar/network.png)
full-load and temperature warning:
![full](.assets/polybar/full.png)
In general, the bar's colors are derived from the colors defined in xresources. It follows the base16 color template, as does every module in these dotfiles. That means the bar can be quickly re-themed using base16 color themes and the process can be automated (e.g. with styler).
## i3 Workspaces
![normal](.assets/polybar/i3-normal.png) -- focus on workspace 4
The i3 workspaces module is pretty simple and self-explanatory. It shows all existing workspaces, and highlights the one that is currently active. It also highlights any workspaces on which an event took place.
![highlight](.assets/polybar/i3-highlight.png) -- focus on workspace 2, workspace 1 highlighted
Additionally, if an i3 mode is active, it will be displayed next to the workspaces in a stark color to notice the mode being active.
![mode](.assets/polybar/i3-mode.png) -- focus on workspace 3, 'Media' mode active
Workspaces can be cycled with the mouse-wheel when hovering over the module, or can be invoked by clicking on the icons.
## Current track information
By default, the track information panel is very minimal. It simply displays a note when something is currently playing, a pause symbol when the current track is pause, and nothing at all when no track is currently available. (no media player open, all tracks stopped, etc.)
When clicked, the track metadata is revealed, displaying track artist and title. Another click toggles it off again.
![mpris](.assets/polybar/mpris.png)
When right-clicked, the current track can be toggled between playing and paused.
The `poly-mprisdisplay` script implementation requires `playerctl` available on the system to be run. It will return with an error message if the binary is not found. Symbols used can be easily customized in the script.
## Date
The standard polybar date display. Displays current date (DD/MM) and current time (24-hours) by default. On click, toggles to an expanded date display with current weekday and current week of the year.
![clock](.assets/polybar/clock.png)
![extended clock](.assets/polybar/clock_alt.png)
## Upcoming Bibtex readings
Depends on the [`bibtex`](bibtex/) module being installed, more specifically:
* the `bib-due` script accessible as a program
* a `$BIBFILE` environment variable pointing to the bibtex library (or at least, the relevant library of the system)
* optionally: `rofi` (or `dmenu`) to enable listing of readings on click
Displays the library readings remaining for the week in simple numerical fashion. On click invokes the full `bib_due` script to show further information on the upcoming readings, requiring either `dmenu` or `rofi` to display them.
## System information
Contains various system-relevant details.
![system info](.assets/polybar/system.png)
If the network has activity, it shows upload and download speeds (dynamically switching between displaying Kb/s, Mb/s). The script `poly-networkspeed` as of now uses hard-coded network interface names. If network interfaces have a different name, this will need to be adjusted.
If updates for arch packages are available (from repositories or aur) it displays the number of available updates. The script `poly-archupdates` requires `yay` to be available. If checkupdates is available it will use this to check for repo packages, which can avoid partial arch updates in rare circumstances. (contained in `pacman-contrib` package)
The volume module simply displays the current pulseaudio volume as a ramped version of the volume symbol. On click it toggles mute and un-mute.
If xbacklight is available, the current display brightness is displayed as a symbol between a moon (dark) and a sun (bright).
If a battery is available, it will display its current status, percentage, and whether it is charging.
The cpu load is displayed as a simple vertical bar, changing color at specific intervals to be more noticeable. When the cpu gets warm, a temperature warning will be displayed, along with current numeric temperature value (in °C). The correct sensor may have to be changed in the polybar config file; as well as useful limits for the display of temperature information.