-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0l
executable file
·56 lines (48 loc) · 1.49 KB
/
0l
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
#! /usr/bin/env tclsh
###############################################################################
# 0l: desktop utility for reading logs (presumes socklog on void)
source $::env(HOME)/bin/lib.tcl
###############################################################################
set arg [lindex $::argv 0]
set dir /var/log/socklog
set what {_}
set dmesg false
proc help {} {
ufail {[what]
_ user session o old user session
a all b debug d daemon e errors
k kernel l dmesg m msgs s secure
u user p xbps}
}
switch -- $arg {
{} - w - wayland - x - xorg - wm - o - old {
set dir $::env(HOME)/log
set what wayland.log
if {{x} eq $SESS} { set what x.log }
if {{o} eq [string index $arg 0]} { set what "$what.old" }
}
l - dmesg { set dmesg true }
a - all { set what everything }
b - debug { set what debug }
d - daemon { set what daemon }
e - errors { set what errors }
k - kernel { set what kernel }
m - messages { set what messages }
p - xbps { set what xbps }
s - secure { set what secure }
u - user { set what user }
}
set log $dir/$what
if {[string match "*/$::env(USER)/log" $dir]} {
if {[file readable $log]} {
exec -- >@stdout 2>@stdout less $log
} else {
fail "$log unreadable"
}
} elseif {$dmesg} {
exec -- >@stdout 2>@stdout /usr/bin/sudo /usr/bin/dmesg --color=always | less
} elseif {[file isdirectory $log]} {
exec -- >@stdout 2>@stdout less $log/current
} else {
help
}