v0.5.0 c37833b

vev-bar-top-right RawHistoryFolder

1#!/bin/sh
2
3# Print a compact, single-line system summary for vev's top-right bar anchor.
4# When available, segments are ordered as workspace, CPU, memory, then clock.
5# Segments that cannot be read are omitted without producing stderr.
6#
7# The workspace segment needs the NeferWL compositor and a local client
8# (VEV_CLIENT_PID set), plus jq. It shows the client's monitor and its workspaces,
9# e.g. "DP-2 [x][ ][ ]". A remote client or another compositor omits it.
10
11workspace=
12if [ -n "${VEV_CLIENT_PID:-}" ] && command -v neferwl >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
13	workspace=$(
14		neferwl state output-of "$VEV_CLIENT_PID" 2>/dev/null |
15			jq -r '
16				if .workspace != "" and .active == 0 then "\(.name) \(.workspace)"
17				else "\(.name) " + ([range(1; .count + 1) as $i | if $i == .active then "[x]" else "[ ]" end] | join(""))
18				end
19			' 2>/dev/null || true
20	)
21fi
22
23now=$(date +%H:%M 2>/dev/null || true)
24
25cpu_pct=
26if [ -r /proc/stat ]; then
27	first=$(awk '$1 == "cpu" { idle = $5 + $6; total = 0; for (i = 2; i <= NF; i++) total += $i; print idle, total; exit }' /proc/stat 2>/dev/null || true)
28	sleep 0.1 2>/dev/null || true
29	second=$(awk '$1 == "cpu" { idle = $5 + $6; total = 0; for (i = 2; i <= NF; i++) total += $i; print idle, total; exit }' /proc/stat 2>/dev/null || true)
30	if [ -n "$first" ] && [ -n "$second" ]; then
31		cpu_pct=$(
32			awk -v first="$first" -v second="$second" '
33				BEGIN {
34					split(first, a, " ")
35					split(second, b, " ")
36					idle = b[1] - a[1]
37					total = b[2] - a[2]
38					if (total > 0) printf "%d", ((total - idle) * 100) / total
39				}
40			' 2>/dev/null || true
41		)
42	fi
43fi
44
45mem_pct=
46if [ -r /proc/meminfo ]; then
47	mem_pct=$(
48		awk '
49			$1 == "MemTotal:" { total = $2 }
50			$1 == "MemAvailable:" { available = $2 }
51			END {
52				if (total > 0 && available >= 0) printf "%d", ((total - available) * 100) / total
53			}
54		' /proc/meminfo 2>/dev/null || true
55	)
56fi
57
58line=$workspace
59if [ -n "$cpu_pct" ]; then
60	if [ -n "$line" ]; then
61		line="$line C $cpu_pct%"
62	else
63		line="C $cpu_pct%"
64	fi
65fi
66if [ -n "$mem_pct" ]; then
67	if [ -n "$line" ]; then
68		line="$line M $mem_pct%"
69	else
70		line="M $mem_pct%"
71	fi
72fi
73if [ -n "$now" ]; then
74	if [ -n "$line" ]; then
75		line="$line $now"
76	else
77		line="$now"
78	fi
79fi
80
81printf '%s\n' "$line"

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close