From eb0e13e7945d36874b8a1f8d20ce698045a2be5a Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Thu, 12 May 2022 20:25:26 -0700 Subject: [PATCH 1/5] Patch st to use .Xresources Enables support for HiDPI systems --- setup/linux/packages/custom/st/PKGBUILD | 4 ++-- setup/linux/profile_gui/airootfs/etc/skel/.Xresources | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 setup/linux/profile_gui/airootfs/etc/skel/.Xresources diff --git a/setup/linux/packages/custom/st/PKGBUILD b/setup/linux/packages/custom/st/PKGBUILD index 78516c11..7167893e 100644 --- a/setup/linux/packages/custom/st/PKGBUILD +++ b/setup/linux/packages/custom/st/PKGBUILD @@ -15,7 +15,7 @@ source=(https://dl.suckless.org/$pkgname/$pkgname-$pkgver.tar.gz terminfo.patch README.terminfo.rst https://st.suckless.org/patches/alpha/st-alpha-20220206-0.8.5.diff - st-colors.diff + https://st.suckless.org/patches/xresources/st-xresources-20200604-9ba7ecf.diff https://st.suckless.org/patches/delkey/st-delkey-20201112-4ef0cbd.diff st-desktopentry-0.8.4-edit.diff https://st.suckless.org/patches/scrollback/st-scrollback-20210507-4536f46.diff @@ -27,7 +27,7 @@ sha256sums=('ea6832203ed02ff74182bcb8adaa9ec454c8f989e79232cb859665e2f544ab37' 'f9deea445a5c6203a0e8e699f3c3b55e27275f17fb408562c4dd5d649edeea23' '0ebcbba881832adf9c98ce9fe7667c851d3cc3345077cb8ebe32702698665be2' '42e4803ce2a67835f7e533a707a8a28e3804a26ced163145108970b9aee5fb81' - '1758a0930a06bf51497923bbd0b1d88a33d4ed4deb770fd85e56e5170c3a2c5b' + '5be9b40d2b51761685f6503e92028a7858cc6571a8867b88612fce8a70514d5b' '946051d123dfe21d8f5ef0f1070c473443f4779dc0bd7edf7c8497f67e325a49' '51d22293b6a2c19471f31160bfebf832dfe2a2768e226520d46c3321d7592649' '19d8f4e7fd0d1933dc6fcf6c7333db08e1b40fc75795464660c4d723eb62511c' diff --git a/setup/linux/profile_gui/airootfs/etc/skel/.Xresources b/setup/linux/profile_gui/airootfs/etc/skel/.Xresources new file mode 100644 index 00000000..eb945d92 --- /dev/null +++ b/setup/linux/profile_gui/airootfs/etc/skel/.Xresources @@ -0,0 +1,2 @@ +! st +st.font: Hack:pixelsize=12:antialias=true:autohint=true From 19e86e0ba0d8828ea435d4ef59e611db49057c7e Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Thu, 12 May 2022 20:32:19 -0700 Subject: [PATCH 2/5] Update HiDPI sections --- .../profile_gui/airootfs/etc/skel/.Xresources | 3 +++ .../airootfs/etc/skel/.config/rofi/config.rasi | 4 ++-- .../profile_gui/airootfs/etc/skel/.update_x | 18 +++++++++--------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/setup/linux/profile_gui/airootfs/etc/skel/.Xresources b/setup/linux/profile_gui/airootfs/etc/skel/.Xresources index eb945d92..562fe4dd 100644 --- a/setup/linux/profile_gui/airootfs/etc/skel/.Xresources +++ b/setup/linux/profile_gui/airootfs/etc/skel/.Xresources @@ -1,2 +1,5 @@ +! Fonts +!Xft.dpi: 192 + ! st st.font: Hack:pixelsize=12:antialias=true:autohint=true diff --git a/setup/linux/profile_gui/airootfs/etc/skel/.config/rofi/config.rasi b/setup/linux/profile_gui/airootfs/etc/skel/.config/rofi/config.rasi index 2864512b..7749dbde 100644 --- a/setup/linux/profile_gui/airootfs/etc/skel/.config/rofi/config.rasi +++ b/setup/linux/profile_gui/airootfs/etc/skel/.config/rofi/config.rasi @@ -1,6 +1,6 @@ /** Basic config file **/ configuration { - show-icons: true; - icon-theme: "Papirus"; + show-icons: true; + icon-theme: "Papirus"; } diff --git a/setup/linux/profile_gui/airootfs/etc/skel/.update_x b/setup/linux/profile_gui/airootfs/etc/skel/.update_x index 2cc26c43..95eb986f 100755 --- a/setup/linux/profile_gui/airootfs/etc/skel/.update_x +++ b/setup/linux/profile_gui/airootfs/etc/skel/.update_x @@ -36,25 +36,25 @@ echo "Done" if [[ "${dpi}" -ge 192 ]]; then echo -n "Updating settings for HiDPI... " - # Conky - sed -i 's/default_graph_height = 24/default_graph_height = 48/' "${HOME}/.config/conky/base.conf" - sed -i 's/gap_x = 20/gap_x = 40/' "${HOME}/.config/conky/base.conf" - sed -i 's/gap_y = 24/gap_y = 48/' "${HOME}/.config/conky/base.conf" - sed -i 's/maximum_width = 180/maximum_width = 360/' "${HOME}/.config/conky/base.conf" - sed -i 's/minimum_width = 180/minimum_width = 360/' "${HOME}/.config/conky/base.conf" - # Fonts sed -i 's/!Xft.dpi: 192/Xft.dpi: 192/' "${HOME}/.Xresources" + sed -i 's/pixelsize=12/pixelsize=24/' "${HOME}/.Xresources" # GDK export GDK_SCALE=2 export GDK_DPI_SCALE=0.5 # Rofi - sed -i -r 's/Noto Sans 12/Noto Sans 24/' "${HOME}/.config/rofi/config" + sed -i -r 's/}/ dpi: 1;\n}/' "${HOME}/.config/rofi/config.rasi" + sed -i 's/10px/20px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi" + sed -i 's/12px/24px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi" + sed -i 's/15px/30px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi" + sed -i 's/20px/40px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi" + sed -i 's/40px/80px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi" + sed -i 's/800px/2000px/' "${HOME}/.config/rofi/applets/menu/configs/rounded/powermenu.rasi" # Tint2 - sed -i 's/panel_size = 100% 30/panel_size = 100% 60/' \ + sed -i 's/panel_size = 99% 30/panel_size = 99% 60/' \ "${HOME}/.config/tint2/tint2rc" sed -i 's/Hack 10/Hack 20/g' \ "${HOME}/.config/tint2/tint2rc" From 47308c150848fb4afa3233faa3814822b1fcae2b Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 14 May 2022 16:19:18 -0700 Subject: [PATCH 3/5] Allow non-integer number of minute countdowns --- scripts/wk/hw/diags.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/wk/hw/diags.py b/scripts/wk/hw/diags.py index 1307190a..f0b047af 100644 --- a/scripts/wk/hw/diags.py +++ b/scripts/wk/hw/diags.py @@ -815,6 +815,7 @@ def main() -> None: def print_countdown(proc, seconds) -> None: """Print countdown to screen while proc is alive.""" + seconds = int(seconds) for i in range(seconds): sec_left = (seconds - i) % 60 min_left = int((seconds - i) / 60) From 0ecc4d41468dcd16ce5b0fcdc506392563038239 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 14 May 2022 17:34:11 -0700 Subject: [PATCH 4/5] Add test mode to Hardware Diagnostics Addresses issue #192 --- scripts/wk/cfg/hw.py | 2 ++ scripts/wk/hw/benchmark.py | 10 +++++++--- scripts/wk/hw/diags.py | 35 +++++++++++++++++++++-------------- scripts/wk/hw/surface_scan.py | 7 ++++++- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/scripts/wk/cfg/hw.py b/scripts/wk/cfg/hw.py index e0ae4cd8..c9bc28f0 100644 --- a/scripts/wk/cfg/hw.py +++ b/scripts/wk/cfg/hw.py @@ -151,6 +151,8 @@ TEMP_COLORS = { 100: 'ORANGE_RED', } TESTSTATION_FILE = '/run/archiso/bootmnt/teststation.name' +TEST_MODE_BADBLOCKS_LIMIT = '10000' # Last block to read +TEST_MODE_CPU_LIMIT = 0.25 # Number of minutes to test # THRESHOLDS: Rates used to determine HDD/SSD pass/fail THRESH_HDD_MIN = 50 * 1024**2 THRESH_HDD_AVG_HIGH = 75 * 1024**2 diff --git a/scripts/wk/hw/benchmark.py b/scripts/wk/hw/benchmark.py index 2ee08577..fd8e86db 100644 --- a/scripts/wk/hw/benchmark.py +++ b/scripts/wk/hw/benchmark.py @@ -38,7 +38,7 @@ class DeviceTooSmallError(RuntimeError): # Functions -def calc_io_dd_values(dev_size) -> dict[str, int]: +def calc_io_dd_values(dev_size, test_mode=False) -> dict[str, int]: """Calculate I/O benchmark dd values, returns dict. Calculations: @@ -63,7 +63,11 @@ def calc_io_dd_values(dev_size) -> dict[str, int]: This is needed to ensure an even testing across the dev This is calculated by using the fractional amount left off of the skip_blocks variable + + test_mode limits the benchmark to IO_MINIMUM_TEST_SIZE (if possible) """ + if test_mode: + dev_size = min(IO_MINIMUM_TEST_SIZE, dev_size) read_total = min(IO_MINIMUM_TEST_SIZE, dev_size) read_total = max(read_total, dev_size*IO_ALT_TEST_SIZE_FACTOR) read_chunks = int(read_total // IO_CHUNK_SIZE) @@ -135,7 +139,7 @@ def check_io_results(test_obj, rate_list, graph_width) -> None: test_obj.set_status('Unknown') -def run_io_test(test_obj, log_path) -> None: +def run_io_test(test_obj, log_path, test_mode=False) -> None: """Run I/O benchmark and handle exceptions.""" dev_path = test_obj.dev.path if PLATFORM == 'Darwin': @@ -148,7 +152,7 @@ def run_io_test(test_obj, log_path) -> None: # Get dd values or bail try: - dd_values = calc_io_dd_values(test_obj.dev.size) + dd_values = calc_io_dd_values(test_obj.dev.size, test_mode=test_mode) except DeviceTooSmallError: test_obj.set_status('N/A') test_obj.report.append( diff --git a/scripts/wk/hw/diags.py b/scripts/wk/hw/diags.py index f0b047af..05fef3e3 100644 --- a/scripts/wk/hw/diags.py +++ b/scripts/wk/hw/diags.py @@ -37,6 +37,7 @@ Options: -c --cli Force CLI mode -h --help Show this page -q --quick Skip menu and perform a quick check + -t --test-mode Run diags in test mode ''' LOG = logging.getLogger(__name__) TEST_GROUPS = { @@ -368,7 +369,7 @@ def build_menu(cli_mode=False, quick_mode=False) -> std.Menu: return menu -def cpu_stress_tests(state, test_objects) -> None: +def cpu_stress_tests(state, test_objects, test_mode=False) -> None: # pylint: disable=too-many-statements """CPU & cooling check using Prime95 and Sysbench.""" LOG.info('CPU Test (Prime95)') @@ -376,6 +377,9 @@ def cpu_stress_tests(state, test_objects) -> None: prime_log = pathlib.Path(f'{state.log_dir}/prime.log') run_sysbench = False sensors_out = pathlib.Path(f'{state.log_dir}/sensors.out') + test_minutes = cfg.hw.CPU_TEST_MINUTES + if test_mode: + test_minutes = cfg.hw.TEST_MODE_CPU_LIMIT test_mprime_obj, test_cooling_obj = test_objects # Bail early @@ -420,7 +424,7 @@ def cpu_stress_tests(state, test_objects) -> None: # Show countdown print('') try: - print_countdown(proc=proc_mprime, seconds=cfg.hw.CPU_TEST_MINUTES*60) + print_countdown(proc=proc_mprime, seconds=test_minutes*60) except KeyboardInterrupt: aborted = True @@ -464,7 +468,7 @@ def cpu_stress_tests(state, test_objects) -> None: pane=state.panes['Prime95'], ) try: - print_countdown(proc=proc_sysbench, seconds=cfg.hw.CPU_TEST_MINUTES*60) + print_countdown(proc=proc_sysbench, seconds=test_minutes*60) except AttributeError: # Assuming the sysbench process wasn't found and proc was set to None LOG.error('Failed to find sysbench process', exc_info=True) @@ -496,7 +500,8 @@ def cpu_stress_tests(state, test_objects) -> None: raise std.GenericAbort('Aborted') -def disk_attribute_check(state, test_objects) -> None: +def disk_attribute_check(state, test_objects, test_mode=False) -> None: + # pylint: disable=unused-argument """Disk attribute check.""" LOG.info('Disk Attribute Check') for test in test_objects: @@ -510,7 +515,8 @@ def disk_attribute_check(state, test_objects) -> None: state.update_progress_pane() -def disk_io_benchmark(state, test_objects, skip_usb=True) -> None: +def disk_io_benchmark( + state, test_objects, skip_usb=True, test_mode=False) -> None: """Disk I/O benchmark using dd.""" LOG.info('Disk I/O Benchmark (dd)') aborted = False @@ -546,7 +552,7 @@ def disk_io_benchmark(state, test_objects, skip_usb=True) -> None: ) state.update_progress_pane() try: - hw_benchmark.run_io_test(test, test_log) + hw_benchmark.run_io_test(test, test_log, test_mode=test_mode) except KeyboardInterrupt: aborted = True except (subprocess.CalledProcessError, TypeError, ValueError) as err: @@ -573,7 +579,8 @@ def disk_io_benchmark(state, test_objects, skip_usb=True) -> None: raise std.GenericAbort('Aborted') -def disk_self_test(state, test_objects) -> None: +def disk_self_test(state, test_objects, test_mode=False) -> None: + # pylint: disable=unused-argument """Disk self-test if available.""" LOG.info('Disk Self-Test(s)') aborted = False @@ -652,7 +659,7 @@ def disk_smart_status_check(dev, mid_run=True) -> None: # Set Disk Attributes test result for test in dev.tests: if test.name == 'Disk Attributes': - test.failed = test.failed or msg + test.failed = bool(test.failed or msg) test.passed = not test.failed if test.failed: test.set_status('Failed') @@ -664,7 +671,7 @@ def disk_smart_status_check(dev, mid_run=True) -> None: dev.disable_disk_tests() -def disk_surface_scan(state, test_objects) -> None: +def disk_surface_scan(state, test_objects, test_mode=False) -> None: """Read-only disk surface scan using badblocks.""" LOG.info('Disk Surface Scan (badblocks)') aborted = False @@ -698,7 +705,7 @@ def disk_surface_scan(state, test_objects) -> None: # Start thread test_log = f'{state.log_dir}/{test.dev.path.name}_badblocks.log' threads.append(exe.start_thread( - hw_surface_scan.run_scan, args=(test, test_log), + hw_surface_scan.run_scan, args=(test, test_log, test_mode), )) # Show progress @@ -758,7 +765,7 @@ def main() -> None: # Quick Mode if args['--quick']: - run_diags(state, menu, quick_mode=True) + run_diags(state, menu, quick_mode=True, test_mode=args['--test-mode']) return # Show menu @@ -807,7 +814,7 @@ def main() -> None: # Start diagnostics if 'Start' in selection: - run_diags(state, menu, quick_mode=False) + run_diags(state, menu, quick_mode=False, test_mode=args['--test-mode']) # Reset top pane state.update_top_pane('Main Menu') @@ -841,7 +848,7 @@ def print_countdown(proc, seconds) -> None: print('') -def run_diags(state, menu, quick_mode=False) -> None: +def run_diags(state, menu, quick_mode=False, test_mode=False) -> None: """Run selected diagnostics.""" aborted = False atexit.register(state.save_debug_reports) @@ -863,7 +870,7 @@ def run_diags(state, menu, quick_mode=False) -> None: args.append(menu.toggles['Skip USB Benchmarks']['Selected']) std.clear_screen() try: - function(state, *args) + function(state, *args, test_mode=test_mode) except (KeyboardInterrupt, std.GenericAbort): aborted = True state.abort_testing() diff --git a/scripts/wk/hw/surface_scan.py b/scripts/wk/hw/surface_scan.py index f3a7212d..f6452bc5 100644 --- a/scripts/wk/hw/surface_scan.py +++ b/scripts/wk/hw/surface_scan.py @@ -9,6 +9,7 @@ from wk.cfg.hw import ( BADBLOCKS_LARGE_DISK, BADBLOCKS_REGEX, BADBLOCKS_SKIP_REGEX, + TEST_MODE_BADBLOCKS_LIMIT, ) from wk.exe import run_program from wk.std import ( @@ -48,7 +49,7 @@ def check_surface_scan_results(test_obj, log_path) -> None: test_obj.set_status('Unknown') -def run_scan(test_obj, log_path) -> None: +def run_scan(test_obj, log_path, test_mode=False) -> None: """Run surface scan and handle exceptions.""" block_size = '1024' dev = test_obj.dev @@ -67,6 +68,10 @@ def run_scan(test_obj, log_path) -> None: # Start scan cmd = ['sudo', 'badblocks', '-sv', '-b', block_size, '-e', '1', dev_path] + if test_mode: + # Only test a limited scope instead of the whole device + cmd.append(TEST_MODE_BADBLOCKS_LIMIT) + with open(log_path, 'a', encoding='utf-8') as _f: size_str = bytes_to_string(dev.size, use_binary=False) _f.write( From 5fc5cda86df4a94e30d57c5b6ea359427e8953c4 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Sat, 14 May 2022 17:51:43 -0700 Subject: [PATCH 5/5] Avoid adding duplicate attribute failure notes --- scripts/wk/hw/diags.py | 10 ++++++---- scripts/wk/hw/disk.py | 10 +++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/wk/hw/diags.py b/scripts/wk/hw/diags.py index 05fef3e3..93980c37 100644 --- a/scripts/wk/hw/diags.py +++ b/scripts/wk/hw/diags.py @@ -115,8 +115,10 @@ class State(): """Check for mid-run SMART failures and failed test(s).""" for dev in self.disks: disk_smart_status_check(dev, mid_run=True) - if any(test.failed for test in dev.tests): - dev.disable_disk_tests() + for test in dev.tests: + if test.failed and 'Attributes' not in test.name: + dev.disable_disk_tests() + break def fix_tmux_layout(self, forced=True) -> None: """Fix tmux layout based on cfg.hw.TMUX_LAYOUT.""" @@ -651,8 +653,8 @@ def disk_smart_status_check(dev, mid_run=True) -> None: color = 'YELLOW' # Log errors if detected - if msg: - msg = f'{msg}{" during diagnostics" if mid_run else ""}.' + if msg and not dev.contains_note(msg): + msg = f'{msg}{" during diagnostics" if mid_run else ""}' LOG.warning(msg) dev.add_note(msg, color) diff --git a/scripts/wk/hw/disk.py b/scripts/wk/hw/disk.py index 9325dbb3..07f4da2e 100644 --- a/scripts/wk/hw/disk.py +++ b/scripts/wk/hw/disk.py @@ -17,7 +17,7 @@ from wk.hw.smart import ( generate_attribute_report, update_smart_details, ) -from wk.std import PLATFORM, bytes_to_string, color_string +from wk.std import PLATFORM, bytes_to_string, color_string, strip_colors # STATIC VARIABLES @@ -76,6 +76,14 @@ class Disk: self.notes.append(note) self.notes.sort() + def contains_note(self, note_str) -> bool: + """Check if note is already present.""" + present = False + for note in self.notes: + if note_str == strip_colors(note): + present = True + return present + def disable_disk_tests(self) -> None: """Disable all tests.""" LOG.warning('Disabling all tests for: %s', self.path)