From d705c64134182364fb662611198ab6570e2f3808 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 8 Sep 2021 09:26:12 -0500 Subject: [PATCH] updating to master --- awesome/init.fnl | 2 +- awesome/keybindings.fnl | 2 +- qutebrowser/autoconfig.yml | 2 +- qutebrowser/qsettings/QtProject.conf | 6 +- rofi/launchers-git/blurry.rasi | 2 +- scripts/scribus-get-embedded-images.py | 80 ++++++++++++++++++++++++++ 6 files changed, 87 insertions(+), 7 deletions(-) create mode 100755 scripts/scribus-get-embedded-images.py diff --git a/awesome/init.fnl b/awesome/init.fnl index 7b26995..df8015b 100644 --- a/awesome/init.fnl +++ b/awesome/init.fnl @@ -644,7 +644,7 @@ (awful.placement.no_offscreen c)) ;; MPV wasn't centering right - ;; (when (= c.class "mpv") (awful.placement.centered c)) + (when (= c.class "mpv") (awful.placement.centered c)) (awful.client.focus.byidx 1) ;; Rounded windows done right diff --git a/awesome/keybindings.fnl b/awesome/keybindings.fnl index c2e1af5..f1b78e3 100644 --- a/awesome/keybindings.fnl +++ b/awesome/keybindings.fnl @@ -167,7 +167,7 @@ {:description "select pass" :group "apps" }) (awful.key [ modkey shift ] "w" (fn [] (awful.spawn "libreoffice --writer")) {:description "Open Writer" :group "apps" }) - (awful.key [modkey] "b" (fn [] (awful.spawn "nyxt")) + (awful.key [modkey] "b" (fn [] (awful.spawn "qutebrowser")) {:description "launch browser" :group "apps"}) ;; rofi (awful.key [] "Menu" (fn [] (awful.spawn "/home/chris/.config/rofi/launchers-git/launcher.sh")) diff --git a/qutebrowser/autoconfig.yml b/qutebrowser/autoconfig.yml index b4556f0..391ae7f 100644 --- a/qutebrowser/autoconfig.yml +++ b/qutebrowser/autoconfig.yml @@ -30,4 +30,4 @@ settings: tabs.show: global: always zoom.default: - global: 150% + global: 100% diff --git a/qutebrowser/qsettings/QtProject.conf b/qutebrowser/qsettings/QtProject.conf index 78a6ec6..7439458 100644 --- a/qutebrowser/qsettings/QtProject.conf +++ b/qutebrowser/qsettings/QtProject.conf @@ -1,8 +1,8 @@ [FileDialog] -history=file:///home/chris -lastVisited=file:///home/chris +history=file:///home/chris, file:///home/chris/Pictures, file:///home/chris/storage/tfc/Documents/newsletterpics +lastVisited=file:///home/chris/storage/tfc/Documents/newsletterpics qtVersion=5.15.2 -shortcuts=file:, file:///home/chris +shortcuts=file:, file:///home/chris, file:///home/chris/storage/tfc sidebarWidth=116 treeViewHeader=@ByteArray(\0\0\0\xff\0\0\0\0\0\0\0\x1\0\0\0\0\0\0\0\x2\x1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x2L\0\0\0\x4\x1\x1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x64\xff\xff\xff\xff\0\0\0\x81\0\0\0\0\0\0\0\x4\0\0\0\xff\0\0\0\x1\0\0\0\0\0\0\0X\0\0\0\x1\0\0\0\0\0\0\0X\0\0\0\x1\0\0\0\0\0\0\0\x9d\0\0\0\x1\0\0\0\0\0\0\x3\xe8\0\xff\xff\xff\xff) viewMode=List diff --git a/rofi/launchers-git/blurry.rasi b/rofi/launchers-git/blurry.rasi index 9d0cb52..825fc22 100644 --- a/rofi/launchers-git/blurry.rasi +++ b/rofi/launchers-git/blurry.rasi @@ -152,7 +152,7 @@ element { } element-icon { - size: 50px; + size: 30px; border: 0px; padding: 0px 0px 0px; } diff --git a/scripts/scribus-get-embedded-images.py b/scripts/scribus-get-embedded-images.py new file mode 100755 index 0000000..b7f2be2 --- /dev/null +++ b/scripts/scribus-get-embedded-images.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Extracts all images that are embedded in a .sla file into individual image files. +© 2019 MIT license, Ale Rimoldi +""" +import os +import sys +import argparse +import re +import zlib +from pathlib import Path +import base64 + +parser = argparse.ArgumentParser(description='Extracts all images that are embedded in a .sla file into individual image files.') +parser.add_argument('in_file', + help='.sla file to be processed.') +parser.add_argument('-o', dest='out_file', action='store', + help='Destination .sla file.') +parser.add_argument('-i', dest='out_images', action='store', + help='Destination directory for the images.') + +args = parser.parse_args() + +SLA_INPUT_FILE = args.in_file +PARENT_PATH = Path(SLA_INPUT_FILE).parent +SLA_OUTPUT_FILE = args.out_file if args.out_file is not None else Path(PARENT_PATH) / (Path(SLA_INPUT_FILE).stem + '-out.sla') +IMAGES_RELATIVE_PATH = 'images' +IMAGES_ABSOLUTE_PATH = args.out_images if args.out_images is not None else Path(PARENT_PATH) / IMAGES_RELATIVE_PATH + +if not os.path.exists(IMAGES_ABSOLUTE_PATH): + print('cannot store images', IMAGES_ABSOLUTE_PATH, 'does not exist') + sys.exit() + # os.makedirs(images_paths) + +p_image_ext = re.compile(r'inlineImageExt="(.+?)"') +p_item_id = re.compile(r'ItemID="(.+?)"') +p_page = re.compile(r'OwnPage="(.+?)"') + +with open(SLA_INPUT_FILE) as sla_input: + with open(SLA_OUTPUT_FILE, 'w') as sla_output: + for line in sla_input: + pos_start = line.find('ImageData') + if pos_start > 0: + image_type = p_image_ext.search(line)[1] + # print(match_image_ext[1]) + item_id = p_item_id.search(line)[1] + page_number = max(int(p_page.search(line)[1]), 0) + + image_file = f'{page_number:03d}-{item_id}.{image_type}' + print(image_file) + + pos_start += 11 + pos_end = line.find('"', pos_start) + with open(Path(IMAGES_ABSOLUTE_PATH) / image_file, 'wb') as image_output: + # images are qcompress(ed) and stored as base64. + # to decompress a qcompress bytes sequence one need to remove the first 4 bytes (size information) + # see https://doc.qt.io/qt-5/qbytearray.html#qUncompress + # see Scribus150Format::pasteItem + decoded = base64.standard_b64decode(line[pos_start:pos_end]) + image_output.write(zlib.decompress(decoded[4:])) + line = line[0:pos_start - 11] + line[pos_end + 1:] + # print(line) + # replace: PFILE="relative url" + # remove: isInlineImage="1" inlineImageExt="*", ImageData="*" + line = line.replace('isInlineImage="1"', '') + line = line.replace(f'inlineImageExt="{image_type}"', '') + line = line.replace('PFILE=""', f'PFILE="{Path(IMAGES_RELATIVE_PATH) / image_file}"') + # re.sub(r'inlineImageExt=".\{-}"', '', line) + # print(line) + # sys.exit() + sla_output.write(line) + + + +# A linked image: +# +# +# An embedded image (with ImageData emptied) +#