Merge branch 'project-overhaul' into dev

This commit is contained in:
2Shirt 2020-01-16 20:33:21 -07:00
commit af80f53666
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
21 changed files with 288 additions and 234 deletions

0
scripts/add-known-networks Normal file → Executable file
View file

View file

@ -13,7 +13,7 @@ if [[ "$os_name" != "Linux" ]]; then
exit 1
fi
source ./launch-in-tmux
source launch-in-tmux
SESSION_NAME="ddrescue-tui"
WINDOW_NAME="ddrescue TUI"

View file

@ -3,7 +3,7 @@
## Wizard Kit: HW Diagnostics Launcher
# TODO: Replace relative paths with absolute
source ./launch-in-tmux
source launch-in-tmux
SESSION_NAME="hw-diags"
WINDOW_NAME="Hardware Diagnostics"

View file

@ -2,6 +2,8 @@
"""Wizard Kit: Mount all volumes"""
# vim: sts=2 sw=2 ts=2
import sys
import wk
@ -19,6 +21,11 @@ def main():
wk.std.print_info('Results')
wk.std.print_report(report, indent=2)
# GUI mode
if 'gui' in sys.argv:
wk.std.pause('Press Enter to exit...')
wk.exe.popen_program(['nohup', 'thunar', '/media'])
if __name__ == '__main__':
if wk.std.PLATFORM != 'Linux':

90
scripts/upload-logs Executable file
View file

@ -0,0 +1,90 @@
#!/usr/bin/env python3
# vim: sts=2 sw=2 ts=2
"""Wizard Kit: Upload Logs"""
import datetime
import os
import pathlib
import pytz
import requests
import wk
# STATIC VARIABLES
LOG_DIR = pathlib.Path('~/Logs').expanduser().resolve()
PLATFORM = wk.std.PLATFORM.replace('Darwin', 'macOS')
TIMEZONE = pytz.timezone(wk.cfg.main.LINUX_TIME_ZONE)
NOW = datetime.datetime.now(tz=TIMEZONE)
# Safety check
if PLATFORM not in ('macOS', 'Linux'):
raise OSError(f'This script is not supported under {PLATFORM}')
# Functions
def main():
"""Upload logs for review."""
lines = []
try_and_print = wk.std.TryAndPrint()
# Set log
wk.log.update_log_path(dest_name='Upload-Logs', timestamp=True)
# Instructions
wk.std.print_success(f'{wk.cfg.main.KIT_NAME_FULL}: Upload Logs')
wk.std.print_standard('')
wk.std.print_standard('Please state the reason for the review.')
wk.std.print_info(' End note with an empty line.')
wk.std.print_standard('')
# Get reason note
while True:
text = wk.std.input_text('> ')
if not text:
lines.append('')
break
lines.append(text)
with open(f'{LOG_DIR}/__reason__.txt', 'a') as _f:
_f.write('\n'.join(lines))
# Compress and upload logs
result = try_and_print.run(
message='Uploading logs...',
function=upload_log_dir,
reason='Review',
)
if not result['Failed']:
raise SystemExit(1)
def upload_log_dir(reason='Testing'):
"""Upload compressed log_dir to the crash server."""
server = wk.cfg.net.CRASH_SERVER
dest = pathlib.Path(f'~/{reason}_{NOW.strftime("%Y-%m-%dT%H%M%S%z")}.txz')
dest = dest.expanduser().resolve()
data = None
# Compress LOG_DIR (relative to parent dir)
os.chdir(LOG_DIR.parent)
cmd = ['tar', 'caf', dest.name, LOG_DIR.name]
proc = wk.exe.run_program(cmd, check=False)
# Upload compressed data
url = f'{server["Url"]}/{dest.name}'
result = requests.put(
url,
data=dest.read_bytes(),
headers=server['Headers'],
auth=(server['User'], server['Pass']),
)
# Check result
if not result.ok:
raise wk.std.GenericError('Failed to upload logs')
if __name__ == '__main__':
main()

31
scripts/wk-exit Executable file
View file

@ -0,0 +1,31 @@
#!/bin/bash
#
## WizardKit: GUI exit script
# Inspired by: https://github.com/cramermarius/rofi-menus/blob/master/scripts/powermenu.sh
actions="Restart\nPoweroff\nLogout"
temp_file="$(mktemp --suffix=.png)"
# Show blurred background
import -window root "${temp_file}"
convert "${temp_file}" -blur 0x4 "${temp_file}"
feh -F "${temp_file}" &
feh_pid="$!"
# Show menu
selection="$(echo -e "$actions" | rofi -i -lines 3 -dmenu -p "Power Menu")"
# Done
kill "${feh_pid}"
case $selection in
Logout)
wk-power-command logout
;;
Poweroff)
wk-power-command poweroff
;;
Restart)
wk-power-command reboot
;;
esac

View file

@ -305,6 +305,13 @@ class State():
working_dir=self.working_dir,
))
def _get_clone_settings_path(self):
"""get Clone settings file path, returns pathlib.Path obj."""
description = self.source.details['model']
if not description:
description = self.source.path.name
return pathlib.Path(f'{self.working_dir}/Clone_{description}.json')
def _fix_tmux_layout(self, forced=True):
"""Fix tmux layout based on cfg.ddrescue.TMUX_LAYOUT."""
layout = cfg.ddrescue.TMUX_LAYOUT
@ -373,9 +380,7 @@ class State():
def _load_settings(self, discard_unused_settings=False):
"""Load settings from previous run, returns dict."""
settings = {}
settings_file = pathlib.Path(
f'{self.working_dir}/Clone_{self.source.details["model"]}.json',
)
settings_file = self._get_clone_settings_path()
# Try loading JSON data
if settings_file.exists():
@ -423,9 +428,7 @@ class State():
def _save_settings(self, settings):
"""Save settings for future runs."""
settings_file = pathlib.Path(
f'{self.working_dir}/Clone_{self.source.details["model"]}.json',
)
settings_file = self._get_clone_settings_path()
# Try saving JSON data
try:
@ -1694,8 +1697,9 @@ def main():
break
# Save results to log
std.print_standard(' ')
std.print_report(state.generate_report())
LOG.info('')
for line in state.generate_report():
LOG.info(' %s', std.strip_colors(line))
def mount_raw_image(path):

View file

@ -138,9 +138,9 @@ def mount_volumes(device_path=None, read_write=False, scan_corestorage=False):
# Attempt to mount volume
if not already_mounted:
mount(vol.path, read_write=read_write)
proc = run_program(cmd, check=False)
if proc.returncode:
try:
mount(vol.path, read_write=read_write)
except RuntimeError:
result += 'Failed to mount'
report.append(std.color_string(result, 'RED'))
continue

View file

@ -10,18 +10,18 @@ set -o pipefail
# Prep
DATE="$(date +%F)"
DATETIME="$(date +%F_%H%M)"
ROOT_DIR="$(realpath $(dirname "$0"))"
BUILD_DIR="$ROOT_DIR/setup/BUILD_LINUX"
ROOT_DIR="$(realpath $(dirname "$0")/..)"
BUILD_DIR="$ROOT_DIR/setup/BUILD"
LIVE_DIR="$BUILD_DIR/live"
LOG_DIR="$BUILD_DIR/logs"
OUT_DIR="$ROOT_DIR/setup/OUT_LINUX"
OUT_DIR="$ROOT_DIR/setup/OUT"
REPO_DIR="$BUILD_DIR/repo"
SKEL_DIR="$LIVE_DIR/airootfs/etc/skel"
TEMP_DIR="$BUILD_DIR/temp"
MIRRORLIST_SOURCE='https://www.archlinux.org/mirrorlist/?country=US&protocol=http&protocol=https&ip_version=4&use_mirror_status=on'
if which nano >/dev/null 2>&1; then
if command -v nano >/dev/null 2>&1; then
EDITOR=nano
elif which vim >/dev/null 2>&1; then
elif command -v vim >/dev/null 2>&1; then
EDITOR=vim
else
EDITOR=vi
@ -130,7 +130,7 @@ function copy_live_env() {
function run_elevated() {
prog="$1"
shift
if which sudo >/dev/null 2>&1; then
if command -v sudo >/dev/null 2>&1; then
if ! sudo "$prog" $*; then
echo "ERROR: Failed to run '$prog'"
if ask "Retry?"; then

View file

@ -4,6 +4,7 @@ alias 7z3='7z a -t7z -mx=3'
alias 7z5='7z a -t7z -mx=5'
alias 7z7='7z a -t7z -mx=7'
alias 7z9='7z a -t7z -mx=9'
alias cdtmp='cd $(mktemp -d)'
alias ddrescue='sudo ddrescue --ask --min-read-rate=64k -vvvv'
alias diff='colordiff -ur'
alias du='du -sch --apparent-size'

View file

@ -1,20 +0,0 @@
[settings]
usehal = false
[looks]
opacity = 70
bgcolor = black
buttontheme = foom
#buttons = cancel, logout, restart, shutdown, suspend, hibernate, lock
buttons = restart, shutdown, logout
[shortcuts]
cancel = Escape
shutdown = S
restart = R
logout = L
[commands]
shutdown = /usr/local/bin/wk-power-command poweroff
restart = /usr/local/bin/wk-power-command reboot
logout = /usr/local/bin/wk-power-command logout

View file

@ -0,0 +1,102 @@
--[[
WizardKit: Conky Config
Based on the Bunsen Labs / Crunchbang Conky configs.
]]
conky.config = {
-- Window properties
background = true,
double_buffer = true,
own_window = true,
own_window_class = 'Conky',
own_window_hints = undecorated,below,skip_taskbar,skip_pager,sticky,
own_window_transparent = false,
own_window_type = 'desktop',
own_window_argb_value = 224,
own_window_argb_visual = true,
-- Borders & Graphs
border_inner_margin = 5,
border_outer_margin = 0,
border_width = 2,
draw_borders = false,
draw_graph_borders = true,
show_graph_range = false,
show_graph_scale = false,
stippled_borders = 5,
-- Colors
-- default_color 656667 # Waldorf original colour
-- default_color 7a7a7a # Flame & Bunsen Grey
-- default_color 929292 # Labs Grey
color0 = 'B0E0E6', -- PowderBlue
color1 = '778899', -- LightSlateGray
color2 = 'D8BFD8', -- Thistle
color3 = '9ACD32', -- YellowGreen
color4 = 'FFA07A', -- LightSalmon
color5 = 'FFDEAD', -- NavajoWhite
color6 = '00BFFF', -- DeepSkyBlue
color7 = '5F9EA0', -- CadetBlue
color8 = 'BDB76B', -- DarkKhaki
color9 = 'CD5C5C', -- IndianRed
default_color = 'C0C0C0', -- Silver
default_outline_color = 'black',
default_shade_color = 'black',
-- Font
draw_outline = false,
draw_shades = false,
extra_newline = false,
font = 'Inconsolata:bold:size=9',
uppercase = false,
use_xft = true,
-- Size & Placement
alignment = 'top_right',
gap_x = 20,
gap_y = 24,
maximum_width = 180,
minimum_height = 5,
minimum_width = 180,
-- Misc
cpu_avg_samples = 2,
net_avg_samples = 2,
no_buffers = true,
out_to_console = false,
out_to_ncurses = false,
out_to_stderr = false,
out_to_x = true,
update_interval = 1.0,
use_spacer = 'none',
}
conky.text = [[
${color}${alignc}S Y S T E M I N F O
${hr}
Date:${alignr}${time %F}
Time:${alignr}${time %H:%M}
Uptime:${alignr}${uptime_short}
CPU: ${if_match ${cpu cpu0}<10} ${cpu cpu0}\
${else}${if_match ${cpu cpu0}<100} ${cpu cpu0}\
${else}${cpu cpu0}${endif}${endif}% Used${alignr}${freq_g} GHz
${cpugraph cpu0 ${gap_x},${width} ${color} ${color}}
RAM: ${mem} Used${alignr}${memmax}
${memgraph ${gap_x},${width} ${color} ${color}}
#Network
${alignc}S H O R T C U T K E Y S
${hr}
[Super] + d${alignr}HW Diagnostics
[Super] + f${alignr}File Manager
[Super] + i${alignr}HW Information
[Super] + m${alignr}Mount Volumes
[Super] + r${alignr}Run Dialog
[Super] + s${alignr}SMART Check
[Super] + t${alignr}Terminal
[Super] + v${alignr}View Temps
[Super] + w${alignr}Web Browser
[Super] + x${alignr}Logout
]]

View file

@ -77,7 +77,7 @@ bindsym $ctrl+$alt+i exec "hardinfo"
bindsym $ctrl+$alt+m exec "urxvt -title 'Mount All Volumes' -e mount-all-volumes gui"
bindsym $ctrl+$alt+s exec "urxvt -title 'Hardware Diagnostics' -e hw-diags --quick"
bindsym $ctrl+$alt+t exec "urxvt"
bindsym $ctrl+$alt+v exec "urxvt -title 'Hardware Sensors' -e watch -c -n1 -t hw-sensors"
bindsym $ctrl+$alt+v exec "urxvt -title 'Hardware Sensors' -e hw-sensors"
bindsym $ctrl+$alt+w exec "firefox"
bindsym $mod+d exec "urxvt -title 'Hardware Diagnostics' -e hw-diags"
bindsym $mod+f exec "thunar ~"
@ -85,7 +85,7 @@ bindsym $mod+i exec "hardinfo"
bindsym $mod+m exec "urxvt -title 'Mount All Volumes' -e mount-all-volumes gui"
bindsym $mod+s exec "urxvt -title 'Hardware Diagnostics' -e hw-diags --quick"
bindsym $mod+t exec "urxvt"
bindsym $mod+v exec "urxvt -title 'Hardware Sensors' -e watch -c -n1 -t hw-sensors"
bindsym $mod+v exec "urxvt -title 'Hardware Sensors' -e hw-sensors"
bindsym $mod+w exec "firefox"
focus_follows_mouse no

View file

@ -334,7 +334,7 @@
</keybind>
<keybind key="C-A-v">
<action name="Execute">
<command>urxvt -title "Hardware Sensors" -e watch -c -n1 -t hw-sensors</command>
<command>urxvt -title "Hardware Sensors" -e hw-sensors</command>
</action>
</keybind>
<keybind key="C-A-w">
@ -344,7 +344,7 @@
</keybind>
<keybind key="C-A-x">
<action name="Execute">
<command>oblogout</command>
<command>wk-exit</command>
</action>
</keybind>
<keybind key="W-d">
@ -384,7 +384,7 @@
</keybind>
<keybind key="W-v">
<action name="Execute">
<command>urxvt -title "Hardware Sensors" -e watch -c -n1 -t hw-sensors</command>
<command>urxvt -title "Hardware Sensors" -e hw-sensors</command>
</action>
</keybind>
<keybind key="W-w">
@ -394,7 +394,7 @@
</keybind>
<keybind key="W-x">
<action name="Execute">
<command>oblogout</command>
<command>wk-exit</command>
</action>
</keybind>
<keybind key="XF86AudioRaiseVolume">

View file

@ -1,10 +0,0 @@
#!/bin/bash
CONKY_RC="$HOME/.conkyrc"
if [[ -f "/run/archiso/bootmnt/arch/conky.rc" ]]; then
CONKY_RC="/run/archiso/bootmnt/arch/conky.rc"
fi
sleep 2s && conky -c "${CONKY_RC}" -dq
sleep 5s && killall conky -c "${CONKY_RC}" -dq

View file

@ -1,165 +0,0 @@
# For commands above TEXT check:
# http://conky.sourceforge.net/config_settings.html
#
# For commands available below TEXT check:
# http://conky.sourceforge.net/variables.html
# Bunsen Labs Conky help threads
# http://crunchbang.org/forums/viewtopic.php?pid=371424#p371424
# beta tested by: smacz
# Enjoy! :)
# pkill -xf "conky -q -c $HOME/.config/conky/BL-Default.conkyrc" &
### Begin Window Settings #####################
own_window yes
#own_window_type override
own_window_transparent no
own_window_hints undecorated,below,skip_taskbar,skip_pager,sticky
own_window_colour 000000
own_window_class Conky
#own_window_title Bunsen Labs Default Conky
own_window_title Default Conky
### ARGB can be used for real transparency
### NOTE that a composite manager is required for real transparency.
### This option will not work as desired (in most cases) in conjunction with
### own_window_type normal
own_window_argb_visual yes # Options: yes or no
### When ARGB visuals are enabled, this use this to modify the alpha value
### Use: own_window_type normal
### Use: own_window_transparent no
### Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
own_window_argb_value 224
minimum_size 180 0 ### width | height
maximum_width 180
gap_x 20 ### left | right
gap_y 24 ### up | down
alignment tr
####################### End Window Settings ###
### Font Settings #############################
# Use Xft (anti-aliased font and stuff)
use_xft yes
xftfont Inconsolata:bold:size=9
#xftfont Liberation Sans:size=9
# Alpha of Xft font. Must be a value at or between 1 and 0 ###
xftalpha 1
# Force UTF8? requires XFT ###
override_utf8_locale yes
uppercase no
######################### End Font Settings ###
### Colour Settings ###########################
draw_shades no #yes
default_shade_color 000000
draw_outline no # amplifies text if yes
default_outline_color 000000
#default_color 656667 # Waldorf original colour
#default_color 7a7a7a # Flame & Bunsen Grey
#default_color 929292 # Labs Grey
default_color C0C0C0 # Silver
color0 B0E0E6 # PowderBlue
color1 778899 # LightSlateGray
color2 D8BFD8 # Thistle
color3 9ACD32 # YellowGreen
color4 FFA07A # LightSalmon
color5 FFDEAD # NavajoWhite
color6 00BFFF # DeepSkyBlue
color7 5F9EA0 # CadetBlue
color8 BDB76B # DarkKhaki
color9 CD5C5C # IndianRed
####################### End Colour Settings ###
### Borders Section ###########################
draw_borders no
# Stippled borders?
stippled_borders 5
# border margins
border_inner_margin 5
border_outer_margin 0
# border width
border_width 2
# graph borders
draw_graph_borders yes #no
#default_graph_size 15 40
####################### End Borders Section ###
### Miscellaneous Section #####################
# Boolean value, if true, Conky will be forked to background when started.
background yes
# Adds spaces around certain objects to stop them from moving other things
# around, this only helps if you are using a mono font
# Options: right, left or none
use_spacer none
# Default and Minimum size is 256 - needs more for single commands that
# "call" a lot of text IE: bash scripts
text_buffer_size 6144
# Subtract (file system) buffers from used memory?
no_buffers yes
# change GiB to G and MiB to M
short_units yes
# Like it says, ot pads the decimals on % values
# doesn't seem to work since v1.7.1
pad_percents 2
# Imlib2 image cache size, in bytes. Default 4MiB Increase this value if you use
# $image lots. Set to 0 to disable the image cache.
imlib_cache_size 0
# Use the Xdbe extension? (eliminates flicker)
# It is highly recommended to use own window with this one
# so double buffer won't be so big.
double_buffer yes
# Maximum size of user text buffer, i.e. layout below TEXT line in config file
# (default is 16384 bytes)
# max_user_text 16384
# Desired output unit of all objects displaying a temperature. Parameters are
# either "fahrenheit" or "celsius". The default unit is degree Celsius.
# temperature_unit Fahrenheit
################# End Miscellaneous Section ###
#### ${font Monospace:bold:size=10}${alignc}${execpi 600 $HOME/.config/conky/scripts/bunsenweather.sh}
update_interval 1
TEXT
${color}${alignc}S Y S T E M I N F O
${hr}
Date:${alignr}${time %F}
Time:${alignr}${time %H:%M}
Uptime:${alignr}${uptime_short}
CPU: ${if_match ${cpu cpu0}<10} ${cpu cpu0}\
${else}${if_match ${cpu cpu0}<100} ${cpu cpu0}\
${else}${cpu cpu0}${endif}${endif}% Used${alignr}${freq_g} GHz
${cpugraph cpu0 ${gap_x},${width} ${color} ${color}}
RAM: ${mem} Used${alignr}${memmax}
${memgraph ${gap_x},${width} ${color} ${color}}
Disk I/O:
${diskiograph ${gap_x},${width} ${color} ${color}}
Down: ${downspeed}${goto 115}Up:${alignr}${upspeed}
#Network
${alignc}S H O R T C U T K E Y S
${hr}
[Super] + d${alignr}HW Diagnostics
[Super] + f${alignr}File Manager
[Super] + i${alignr}HW Information
[Super] + m${alignr}Mount Volumes
[Super] + r${alignr}Run Dialog
[Super] + s${alignr}SMART Check
[Super] + t${alignr}Terminal
[Super] + v${alignr}View Temps
[Super] + w${alignr}Web Browser
[Super] + x${alignr}Logout

View file

@ -3,8 +3,7 @@
## Start desktop apps based on WM
# Start common apps
feh --bg-fill "$HOME/.wallpaper"
compton --backend xrender --xrender-sync --xrender-sync-fence &
picom --backend xrender --xrender-sync --xrender-sync-fence &
sleep 1s
x0vncserver -display :0 -passwordfile $HOME/.vnc/passwd -AlwaysShared &
conky &
@ -12,7 +11,7 @@ nm-applet &
volumeicon &
# Start WM specific apps
if fgrep -q "i3" /proc/cmdline; then
if ! [[ "${I3SOCK:-}" == "" ]]; then
# i3
i3-msg restart
else

View file

@ -1,24 +1,36 @@
#!/bin/bash
# vim: sts=2 sw=2 ts=2
CONFIG_BASE="${HOME}/.config/conky/base.conf"
CONFIG_NEW="${HOME}/.config/conky/new.conf"
CONFIG_REAL="${HOME}/.config/conky/conky.conf"
IF_LIST=($(ip l \
| egrep '^[0-9]+:\s+(eth|en|wl)' \
| sed -r 's/^[0-9]+:\s+(\w+):.*/\1/' \
| sort))
# Reset conkyrc to default
rm "${HOME}/.conkyrc"
cp "${HOME}/.conkyrc_base" "${HOME}/.conkyrc"
# Build new config from the default
rm "${CONFIG_NEW}"
cp "${CONFIG_BASE}" "${CONFIG_NEW}"
# Add interfaces to conkyrc
# Add interfaces to conkyrc_new
for i in "${IF_LIST[@]}"; do
if [[ "${i:0:1}" == "e" ]]; then
sed -i -r "s/#Network/Wired:\${alignr}\${addr $i}\n#Network/" $HOME/.conkyrc
sed -i -r "s/#Network/Wired:\${alignr}\${addr $i}\n#Network/" "${CONFIG_NEW}"
else
sed -i -r "s/#Network/Wireless:\${alignr}\${addr $i}\n#Network/" $HOME/.conkyrc
sed -i -r "s/#Network/Wireless:\${alignr}\${addr $i}\n#Network/" "${CONFIG_NEW}"
fi
done
sed -i -r "s/#Network//" "${CONFIG_NEW}"
# Remove '#Network' line to prevent duplicating lines if this script is re-run
sed -i -r "s/#Network//" $HOME/.conkyrc
# Fix under i3
if ! [[ "${I3SOCK:-}" == "" ]]; then
sed -i -r 's/(own_window_type)(.*)(desktop)/\1\2override/' "${CONKY_NEW}"
fi
# vim: sts=2 sw=2 ts=2
# Replace config if there were changes
if ! diff -q "${CONFIG_NEW}" "${CONFIG_REAL}" >/dev/null 2>&1; then
rm "${CONFIG_REAL}"
cp "${CONFIG_NEW}" "${CONFIG_REAL}"
fi

View file

@ -91,6 +91,11 @@ xset -dpms
xrdb -merge $HOME/.Xresources
echo "Done"
# Set wallpaper
echo -n "Setting wallpaper... "
feh --bg-fill "$HOME/.wallpaper"
echo "Done"
# Start desktop apps for i3
if fgrep -q "i3" /proc/cmdline; then
i3-msg exec $HOME/.start_desktop_apps

View file

@ -5,7 +5,6 @@ if [ "$(fgconsole 2>/dev/null)" -eq "1" ]; then
# Update settings if using i3
if fgrep -q "i3" /proc/cmdline; then
sed -i -r 's/#(own_window_type override)/\1/' ~/.conkyrc
sed -i -r 's/openbox-session/i3/' ~/.xinitrc
fi

View file

@ -24,7 +24,6 @@ mpv
network-manager-applet
noto-fonts
noto-fonts-cjk
oblogout
openbox-patched
otf-font-awesome-4
papirus-icon-theme