forked from ckb-next/ckb-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ckb-next-dev-detect
executable file
·81 lines (71 loc) · 3.35 KB
/
ckb-next-dev-detect
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env bash
# Newline
N=$'\n'
if [[ "$1" != "--elevate" ]]; then
if [[ "$1" != "--nouserinput" ]]; then
OUTPATH="${PWD}/"
echo "This script will collect information about the Corsair devices in your system."
read -p "Please make sure they are plugged in and press Enter.${N}"
echo "Generating report. Please wait..."
else
OUTPATH="/tmp/"
fi
#Check if user can write to the PWD
touch "${OUTPATH}ckb-next-dev-detect-report.gz"
TOUCHRET=$?
if [ $TOUCHRET -ne 0 ]; then
echo "Could not write the report to disk, make sure this user can write to ${OUTPATH}"
echo "Retval: $TOUCHRET"
exit $TOUCHRET
fi
# If pkexec exists, run the script through it
ABSPATH=`readlink -f "$0"`
if command -v pkexec &> /dev/null; then
OUT="`pkexec \"$ABSPATH\" --elevate`"
RET=$?
if [[ $RET -ne 0 ]]; then
echo "pkexec failed"
exit $RET
fi
else
OUT="pkexec not found${N}${N}`bash \"$ABSPATH\" --elevate`"
fi
OUT="${OUT}${N}${N}Environment:${N}`printenv | grep "QT\|XDG.*DESKTOP\|DISPLAY\|WAYLAND_DESKTOP\|XDG_SESSION_TYPE" 2>&1`"
OUT="${OUT}${N}\`\`\`${N}"
echo "$OUT" | gzip > "${OUTPATH}ckb-next-dev-detect-report.gz"
echo "Done! Please send the following report to the developers."
echo "Location: ${OUTPATH}ckb-next-dev-detect-report.gz"
else
# Force English
export LC_ALL=C
OUT="ckb-next-dev-detect - $(date)"
OUT="${OUT}${N}${N}\`\`\`"
# Applies to both
OUT="${OUT}${N}Kernel: `uname -a`"
if [[ "$OSTYPE" == "darwin"* ]]; then
OUT="${OUT}${N}${N}OS Version:${N}`sw_vers`"
OUT="${OUT}${N}${N}USB Devices:${N}`system_profiler SPUSBDataType -detailLevel mini | grep -i -B3 -A9 1b1c`"
OUT="${OUT}${N}${N}IOReg:${N}`ioreg -lxrc IOUSBDevice | sed -n '/Corsair/,/^$/p'`"
OUT="${OUT}${N}${N}Daemon log:${N}`tail -n 100 /var/log/ckb-next-daemon.log`"
OUT="${OUT}${N}${N}GUI log:${N}`cat /tmp/ckb-next.log`"
else
OUT="${OUT}${N}${N}OS Version:${N}`lsb_release -a 2>/dev/null`"
OUT="${OUT}${N}${N}USB Devices:${N}`lsusb -vd '1b1c:' 2>&1`"
# Check if kernel ring buffer is reachable through systemd journal, fall back to dmesg
if [ -z "$(journalctl -k 2>/dev/null)" ]; then
OUT="${OUT}${N}${N}Systemctl error, falling back to dmesg:${N}`dmesg | grep -i \"ckb-next\|corsair\|1b1c\"`"
else
# Pipe stderr to /dev/null, as grep would filter errors out anyway
OUT="${OUT}${N}${N}Dmesg on current boot:${N}`journalctl -o short-precise -k -b 0 2>/dev/null | grep -i \"ckb-next\|corsair\|1b1c\"`"
OUT="${OUT}${N}${N}Dmesg on last boot:${N}`journalctl -o short-precise -k -b -1 2>/dev/null | grep -i \"ckb-next\|corsair\|1b1c\"`"
OUT="${OUT}${N}${N}Daemon on current boot:${N}`journalctl -o short-precise -b 0 --unit=ckb-next-daemon 2>&1`"
OUT="${OUT}${N}${N}Daemon on last boot:${N}`journalctl -o short-precise -b -1 --unit=ckb-next-daemon 2>&1`"
fi
OUT="${OUT}${N}${N}Dev nodes:${N}`find /dev/input/ckb* -print -type f -exec cat {} \; 2>&1`"
OUT="${OUT}${N}${N}Kernel command line:${N}`cat /proc/cmdline`"
GUIPATH="$(which ckb-next)"
OUT="${OUT}${N}${N}GUI ldd:${N}`ldd ${GUIPATH}`"
fi
# Print to stdout
echo "$OUT"
fi