From b3a4be7f2eb82f3cd7ac12ce316f4fc9cd4cbf76 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 24 Dec 2023 13:28:19 +0300 Subject: [PATCH 01/16] .shellrc: unset `wrapper` --- .shellrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.shellrc b/.shellrc index 5d46454..9f9242a 100644 --- a/.shellrc +++ b/.shellrc @@ -163,7 +163,7 @@ mc() { rc=1 fi - unset MC_FOUND MC_PWD_FILE MC_SLOW MC_TMP_DIR MC_XTERM + unset wrapper MC_FOUND MC_PWD_FILE MC_SLOW MC_TMP_DIR MC_XTERM return $rc } -- 2.39.2 From f6f7a0745ed146812c1e683d197e3cde4d08dc84 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 1 Jan 2024 18:37:04 +0300 Subject: [PATCH 02/16] .vim: Rename `RemoveTrailingSpaces` -> `StripTrailingSpaces` --- .vim/plugin/text.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vim/plugin/text.vim b/.vim/plugin/text.vim index 8fc16f7..77990ed 100644 --- a/.vim/plugin/text.vim +++ b/.vim/plugin/text.vim @@ -2,7 +2,7 @@ function! SearchConflictMarkers() normal /<<<<<<<\|=======\||||||||\|>>>>>>> endfunction -function! RemoveTrailingSpaces() +function! StripTrailingSpaces() %s/ \+$// endfunction -- 2.39.2 From 4bbe03e0938c6215fe7e415c2ebde58c5af4c67c Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Tue, 16 Jan 2024 23:52:52 +0300 Subject: [PATCH 03/16] .fvwmrc: Use `xset s` to activate screensaver Work around a bug in `xscreensaver`. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1040948 --- .fvwm/main.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.fvwm/main.m4 b/.fvwm/main.m4 index 28c707f..034387d 100644 --- a/.fvwm/main.m4 +++ b/.fvwm/main.m4 @@ -866,7 +866,8 @@ AddToMenu Browsers "Choose one:" Title #+ "Blank" Exec exec xlock -mode blank AddToMenu XScreenSaverMenu "Choose mode:" Title -+ "Suspend Screen Now" Exec exec xscreensaver-command --suspend ++ "Activate via xset" Exec exec xset s activate +#+ "Suspend Screen Now" Exec exec xscreensaver-command --suspend + "Activate Screen Now" Exec exec xscreensaver-command --activate + "Lock Screen Now" Exec exec xscreensaver-command --lock + "" Nop -- 2.39.2 From 4012586325e2641a1ea2a960bdeebb7422f3cc9e Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 18 Jan 2024 15:52:04 +0300 Subject: [PATCH 04/16] Feat(.vim/python/virtualenv.py): Search for `activate_this.py` in w32 --- .vim/python/virtualenv.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.vim/python/virtualenv.py b/.vim/python/virtualenv.py index 078a0f8..9341bc7 100644 --- a/.vim/python/virtualenv.py +++ b/.vim/python/virtualenv.py @@ -3,8 +3,14 @@ import sys, os virtualenv_dir = os.environ.get('VIRTUAL_ENV') if virtualenv_dir: sys.path.insert(0, virtualenv_dir) - activate_this = os.path.join(virtualenv_dir, 'bin', 'activate_this.py') - if sys.version_info[0] == 2: - execfile(activate_this, dict(__file__=activate_this)) - else: - exec(open(activate_this, 'r').read(), dict(__file__=activate_this)) + for activate_this in [ + os.path.join(virtualenv_dir, 'bin', 'activate_this.py'), + os.path.join(virtualenv_dir, 'Scripts', 'activate_this.py') + ]: + if not os.path.exists(activate_this): + continue + if sys.version_info[0] == 2: + execfile(activate_this, dict(__file__=activate_this)) + else: + exec(open(activate_this, 'r').read(), dict(__file__=activate_this)) + break -- 2.39.2 From 353abf00b2c4c65a8befd5efa8d992e56667c257 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 18 Jan 2024 15:55:38 +0300 Subject: [PATCH 05/16] Feat(.vim/python/virtualenv.py): Check major Python version Do not activate the current virtual environment if it doesn't correspond to the vim's Python version. --- .vim/python/virtualenv.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.vim/python/virtualenv.py b/.vim/python/virtualenv.py index 9341bc7..ca66bf8 100644 --- a/.vim/python/virtualenv.py +++ b/.vim/python/virtualenv.py @@ -10,7 +10,13 @@ if virtualenv_dir: if not os.path.exists(activate_this): continue if sys.version_info[0] == 2: - execfile(activate_this, dict(__file__=activate_this)) + if os.path.exists( + os.path.join(virtualenv_dir, 'lib', 'python2.7')): + execfile(activate_this, + dict(__file__=activate_this)) else: - exec(open(activate_this, 'r').read(), dict(__file__=activate_this)) + if not os.path.exists( + os.path.join(virtualenv_dir, 'lib', 'python2.7')): + exec(open(activate_this, 'r').read(), + dict(__file__=activate_this)) break -- 2.39.2 From ba2498c10865adb89a57d22bf877bbbd8afa671e Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 18 Jan 2024 18:49:42 +0300 Subject: [PATCH 06/16] .fvwmrc: Run `xset s on` before activating `xscreensaver` sets it to off. Also improve menu titles. --- .fvwm/main.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.fvwm/main.m4 b/.fvwm/main.m4 index 034387d..532cc44 100644 --- a/.fvwm/main.m4 +++ b/.fvwm/main.m4 @@ -866,9 +866,9 @@ AddToMenu Browsers "Choose one:" Title #+ "Blank" Exec exec xlock -mode blank AddToMenu XScreenSaverMenu "Choose mode:" Title -+ "Activate via xset" Exec exec xset s activate -#+ "Suspend Screen Now" Exec exec xscreensaver-command --suspend -+ "Activate Screen Now" Exec exec xscreensaver-command --activate ++ "Blank Screen via xset" Exec xset s on && exec xset s activate +#+ "Blank Screen Now" Exec exec xscreensaver-command --suspend ++ "Activate A Hack Now" Exec exec xscreensaver-command --activate + "Lock Screen Now" Exec exec xscreensaver-command --lock + "" Nop + "Screen Saver Demo" Exec exec xscreensaver-demo -- 2.39.2 From 93c18fafd5df1069242d976e4982c38d74629e17 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 20 Jan 2024 07:13:30 +0300 Subject: [PATCH 07/16] Refactor(.vim/python/virtualenv.py): Optimize code Check Python version once outside the loop. --- .vim/python/virtualenv.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.vim/python/virtualenv.py b/.vim/python/virtualenv.py index ca66bf8..ed46739 100644 --- a/.vim/python/virtualenv.py +++ b/.vim/python/virtualenv.py @@ -1,22 +1,25 @@ -import sys, os +import sys, os # noqa: E401 multiple imports on one line virtualenv_dir = os.environ.get('VIRTUAL_ENV') if virtualenv_dir: - sys.path.insert(0, virtualenv_dir) - for activate_this in [ - os.path.join(virtualenv_dir, 'bin', 'activate_this.py'), - os.path.join(virtualenv_dir, 'Scripts', 'activate_this.py') - ]: - if not os.path.exists(activate_this): - continue - if sys.version_info[0] == 2: - if os.path.exists( - os.path.join(virtualenv_dir, 'lib', 'python2.7')): - execfile(activate_this, + if ( + (sys.version_info[0] == 2) + and os.path.exists( + os.path.join(virtualenv_dir, 'lib', 'python2.7')) + ) or ( + not os.path.exists( + os.path.join(virtualenv_dir, 'lib', 'python2.7')) + ): + for activate_this in [ + os.path.join(virtualenv_dir, 'bin', 'activate_this.py'), + os.path.join(virtualenv_dir, 'Scripts', 'activate_this.py') + ]: + if not os.path.exists(activate_this): + continue + if sys.version_info[0] == 2: + execfile(activate_this, # noqa: F821 undefined name 'execfile' dict(__file__=activate_this)) - else: - if not os.path.exists( - os.path.join(virtualenv_dir, 'lib', 'python2.7')): + else: exec(open(activate_this, 'r').read(), dict(__file__=activate_this)) - break + break -- 2.39.2 From 210cd046d06e1b007c9e9fc89d399e9e3d2a9ce2 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sat, 20 Jan 2024 07:14:26 +0300 Subject: [PATCH 08/16] Style(.vim/python/completion.py): Fix `flake8` warnings --- .vim/python/completion.py | 126 ++++++++++++++++++++------------------ 1 file changed, 68 insertions(+), 58 deletions(-) diff --git a/.vim/python/completion.py b/.vim/python/completion.py index 036aef8..d2681e8 100644 --- a/.vim/python/completion.py +++ b/.vim/python/completion.py @@ -1,71 +1,81 @@ # From http://slobin.pp.ru/vim/_vimrc.html # Adapted to python3 by Oleg Broytman -import sys, rlcompleter, unicodedata, vim -from itertools import * +from itertools import count +import rlcompleter +import sys +import unicodedata + +import vim + + vim_complete = rlcompleter.Completer().complete + def vim_comp_list(): - """Implementation of CompList() function""" - arglead = vim.eval("a:ArgLead") - fence = int(vim.eval("match(a:ArgLead, '\(\w\|\.\)*$')")) - left, right = arglead[:fence], arglead[fence:] - try: - completions = (vim_complete(right, i) for i in count()) - candidates = list(takewhile(bool, completions)) - except NameError: - candidates = [] - suggestions = [left + x for x in candidates] - vim.command("return " + repr(suggestions)) + """Implementation of CompList() function""" + arglead = vim.eval("a:ArgLead") + fence = int(vim.eval("match(a:ArgLead, '\\(\\w\\|\\.\\)*$')")) + left, right = arglead[:fence], arglead[fence:] + try: + completions = (vim_complete(right, i) for i in count()) + candidates = list(takewhile(bool, completions)) + except NameError: + candidates = [] + suggestions = [left + x for x in candidates] + vim.command("return " + repr(suggestions)) + def vim_calc(command): - """Implementation of :Calc command""" - global _ - try: - result = eval(command) - except SyntaxError: - if sys.version_info[0] == 2: - exec(command in globals(), locals()) + """Implementation of :Calc command""" + global _ + try: + result = eval(command) + except SyntaxError: + if sys.version_info[0] == 2: + exec(command in globals(), locals()) + else: + exec(command, globals(), locals()) else: - exec(command, globals(), locals()) - else: - if result != None: - print(result) - _ = result - xx = ''.join(['\\x%02x' % ord(x) for x in str(_)]) - vim.command('let @" = "%s"' % xx) + if result is not None: + print(result) + _ = result + xx = ''.join(['\\x%02x' % ord(x) for x in str(_)]) + vim.command('let @" = "%s"' % xx) + def vim_pydo(command): - """Implementation of :Pydo command""" - codeobj = compile(command, "command", "eval") - line1 = vim.current.range.start - line2 = vim.current.range.end - delta = 0 - for numz in range(line1, line2+1): - line = vim.current.buffer[numz-delta] - if sys.version_info[0] == 2: - uline = unicode(line, vim.eval('&fileencoding')) - else: - uline = line - num = numz + 1 - words = line.split() - result = eval(codeobj, globals(), locals()) - if result is None or result is False: - del vim.current.buffer[numz-delta] - delta += 1 - continue - if isinstance(result, list) or isinstance(result, tuple): - result = " ".join(map(str, result)) - else: - result = str(result) - vim.current.buffer[numz-delta] = result + """Implementation of :Pydo command""" + codeobj = compile(command, "command", "eval") + line1 = vim.current.range.start + line2 = vim.current.range.end + delta = 0 + for numz in range(line1, line2+1): + line = vim.current.buffer[numz-delta] + if sys.version_info[0] == 2: + uline = line.decode(vim.eval('&fileencoding')) + else: + uline = line + num = numz + 1 + words = line.split() + result = eval(codeobj, globals(), locals()) + if result is None or result is False: + del vim.current.buffer[numz-delta] + delta += 1 + continue + if isinstance(result, list) or isinstance(result, tuple): + result = " ".join(map(str, result)) + else: + result = str(result) + vim.current.buffer[numz-delta] = result + def vim_unicode_name(): - try: - char = vim.eval("matchstr(getline('.'), '.', col('.') - 1)") - if sys.version_info[0] == 2: - print(unicodedata.name(char.decode(vim.eval("&encoding")))) - else: - print(unicodedata.name(char)) - except (AttributeError, ValueError) as target: - print("%s: %s" % (target.__class__.__name__, target)) + try: + char = vim.eval("matchstr(getline('.'), '.', col('.') - 1)") + if sys.version_info[0] == 2: + print(unicodedata.name(char.decode(vim.eval("&encoding")))) + else: + print(unicodedata.name(char)) + except (AttributeError, ValueError) as target: + print("%s: %s" % (target.__class__.__name__, target)) -- 2.39.2 From 638bc28e9d4294118b5484d2c22dd1d88e0d07fc Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 25 Jan 2024 20:17:58 +0300 Subject: [PATCH 09/16] bin: Remove outdated unused scripts --- bin/iconvxml.py | 28 --------- bin/latin1_to_ascii.py | 125 ----------------------------------------- bin/smplay | 22 -------- bin/smplay-gui | 1 - 4 files changed, 176 deletions(-) delete mode 100755 bin/iconvxml.py delete mode 100755 bin/latin1_to_ascii.py delete mode 100755 bin/smplay delete mode 120000 bin/smplay-gui diff --git a/bin/iconvxml.py b/bin/iconvxml.py deleted file mode 100755 index 2892a91..0000000 --- a/bin/iconvxml.py +++ /dev/null @@ -1,28 +0,0 @@ -#! /usr/bin/env python -"Recode using XML char references" - -import sys -from getopt import getopt -from m_lib.defenc import default_encoding - -from_charset = "utf-8" -to_charset = default_encoding - -options, arguments = getopt(sys.argv[1:], 'f:t:') -for option, value in options: - if option == '-f': - from_charset = value - elif option == '-t': - to_charset = value - -if arguments: - for file in arguments: - infile = open(file) - try: - for line in infile: - sys.stdout.write(line.decode(from_charset, "replace").encode(to_charset, "xmlcharrefreplace")) - except: - infile.close() -else: - for line in sys.stdin: - sys.stdout.write(line.decode(from_charset, "replace").encode(to_charset, "xmlcharrefreplace")) diff --git a/bin/latin1_to_ascii.py b/bin/latin1_to_ascii.py deleted file mode 100755 index a2f2145..0000000 --- a/bin/latin1_to_ascii.py +++ /dev/null @@ -1,125 +0,0 @@ -#! /usr/bin/env python - -# See http://code.activestate.com/recipes/251871/ - -import sys, os - -xlate = { - u'\N{ACUTE ACCENT}': "'", - u'\N{BROKEN BAR}': '|', - u'\N{CEDILLA}': '{cedilla}', - u'\N{CENT SIGN}': '{cent}', - u'\N{COPYRIGHT SIGN}': '{C}', - u'\N{CURRENCY SIGN}': '{currency}', - u'\N{DEGREE SIGN}': '{degrees}', - u'\N{DIAERESIS}': '{umlaut}', - u'\N{DIVISION SIGN}': '/', - u'\N{FEMININE ORDINAL INDICATOR}': '{^a}', - u'\N{INVERTED EXCLAMATION MARK}': '!', - u'\N{INVERTED QUESTION MARK}': '?', - u'\N{LATIN CAPITAL LETTER A WITH ACUTE}': 'A', - u'\N{LATIN CAPITAL LETTER A WITH CIRCUMFLEX}': 'A', - u'\N{LATIN CAPITAL LETTER A WITH DIAERESIS}': 'A', - u'\N{LATIN CAPITAL LETTER A WITH GRAVE}': 'A', - u'\N{LATIN CAPITAL LETTER A WITH RING ABOVE}': 'A', - u'\N{LATIN CAPITAL LETTER A WITH TILDE}': 'A', - u'\N{LATIN CAPITAL LETTER AE}': 'Ae', - u'\N{LATIN CAPITAL LETTER C WITH CEDILLA}': 'C', - u'\N{LATIN CAPITAL LETTER E WITH ACUTE}': 'E', - u'\N{LATIN CAPITAL LETTER E WITH CIRCUMFLEX}': 'E', - u'\N{LATIN CAPITAL LETTER E WITH DIAERESIS}': 'E', - u'\N{LATIN CAPITAL LETTER E WITH GRAVE}': 'E', - u'\N{LATIN CAPITAL LETTER ETH}': 'Th', - u'\N{LATIN CAPITAL LETTER I WITH ACUTE}': 'I', - u'\N{LATIN CAPITAL LETTER I WITH CIRCUMFLEX}': 'I', - u'\N{LATIN CAPITAL LETTER I WITH DIAERESIS}': 'I', - u'\N{LATIN CAPITAL LETTER I WITH GRAVE}': 'I', - u'\N{LATIN CAPITAL LETTER N WITH TILDE}': 'N', - u'\N{LATIN CAPITAL LETTER O WITH ACUTE}': 'O', - u'\N{LATIN CAPITAL LETTER O WITH CIRCUMFLEX}': 'O', - u'\N{LATIN CAPITAL LETTER O WITH DIAERESIS}': 'O', - u'\N{LATIN CAPITAL LETTER O WITH GRAVE}': 'O', - u'\N{LATIN CAPITAL LETTER O WITH STROKE}': 'O', - u'\N{LATIN CAPITAL LETTER O WITH TILDE}': 'O', - u'\N{LATIN CAPITAL LETTER THORN}': 'th', - u'\N{LATIN CAPITAL LETTER U WITH ACUTE}': 'U', - u'\N{LATIN CAPITAL LETTER U WITH CIRCUMFLEX}': 'U', - u'\N{LATIN CAPITAL LETTER U WITH DIAERESIS}': 'U', - u'\N{LATIN CAPITAL LETTER U WITH GRAVE}': 'U', - u'\N{LATIN CAPITAL LETTER Y WITH ACUTE}': 'Y', - u'\N{LATIN SMALL LETTER A WITH ACUTE}': 'a', - u'\N{LATIN SMALL LETTER A WITH CIRCUMFLEX}': 'a', - u'\N{LATIN SMALL LETTER A WITH DIAERESIS}': 'a', - u'\N{LATIN SMALL LETTER A WITH GRAVE}': 'a', - u'\N{LATIN SMALL LETTER A WITH RING ABOVE}': 'a', - u'\N{LATIN SMALL LETTER A WITH TILDE}': 'a', - u'\N{LATIN SMALL LETTER AE}': 'ae', - u'\N{LATIN SMALL LETTER C WITH CEDILLA}': 'c', - u'\N{LATIN SMALL LETTER E WITH ACUTE}': 'e', - u'\N{LATIN SMALL LETTER E WITH CIRCUMFLEX}': 'e', - u'\N{LATIN SMALL LETTER E WITH DIAERESIS}': 'e', - u'\N{LATIN SMALL LETTER E WITH GRAVE}': 'e', - u'\N{LATIN SMALL LETTER ETH}': 'th', - u'\N{LATIN SMALL LETTER I WITH ACUTE}': 'i', - u'\N{LATIN SMALL LETTER I WITH CIRCUMFLEX}': 'i', - u'\N{LATIN SMALL LETTER I WITH DIAERESIS}': 'i', - u'\N{LATIN SMALL LETTER I WITH GRAVE}': 'i', - u'\N{LATIN SMALL LETTER N WITH TILDE}': 'n', - u'\N{LATIN SMALL LETTER O WITH ACUTE}': 'o', - u'\N{LATIN SMALL LETTER O WITH CIRCUMFLEX}': 'o', - u'\N{LATIN SMALL LETTER O WITH DIAERESIS}': 'o', - u'\N{LATIN SMALL LETTER O WITH GRAVE}': 'o', - u'\N{LATIN SMALL LETTER O WITH STROKE}': 'o', - u'\N{LATIN SMALL LETTER O WITH TILDE}': 'o', - u'\N{LATIN SMALL LETTER SHARP S}': 'ss', - u'\N{LATIN SMALL LETTER THORN}': 'th', - u'\N{LATIN SMALL LETTER U WITH ACUTE}': 'u', - u'\N{LATIN SMALL LETTER U WITH CIRCUMFLEX}': 'u', - u'\N{LATIN SMALL LETTER U WITH DIAERESIS}': 'u', - u'\N{LATIN SMALL LETTER U WITH GRAVE}': 'u', - u'\N{LATIN SMALL LETTER Y WITH ACUTE}': 'y', - u'\N{LATIN SMALL LETTER Y WITH DIAERESIS}': 'y', - u'\N{LEFT-POINTING DOUBLE ANGLE QUOTATION MARK}': '<<', - u'\N{MACRON}': '_', - u'\N{MASCULINE ORDINAL INDICATOR}': '{^o}', - u'\N{MICRO SIGN}': '{micro}', - u'\N{MIDDLE DOT}': '*', - u'\N{MULTIPLICATION SIGN}': '*', - u'\N{NOT SIGN}': '{not}', - u'\N{PILCROW SIGN}': '{paragraph}', - u'\N{PLUS-MINUS SIGN}': '{+/-}', - u'\N{POUND SIGN}': '{pound}', - u'\N{REGISTERED SIGN}': '{R}', - u'\N{RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK}': '>>', - u'\N{SECTION SIGN}': '{section}', - u'\N{SOFT HYPHEN}': '-', - u'\N{SUPERSCRIPT ONE}': '{^1}', - u'\N{SUPERSCRIPT THREE}': '{^3}', - u'\N{SUPERSCRIPT TWO}': '{^2}', - u'\N{VULGAR FRACTION ONE HALF}': '{1/2}', - u'\N{VULGAR FRACTION ONE QUARTER}': '{1/4}', - u'\N{VULGAR FRACTION THREE QUARTERS}': '{3/4}', - u'\N{YEN SIGN}': '{yen}' -} - -def latin1_to_ascii(uinput): - if isinstance(uinput, bytes): - uinput = uinput.decode(sys.getfilesystemencoding()) - out = [] - for c in uinput: - i = ord(c) - if i in xlate: - out.append(xlate[i]) - elif i >= 0x80: - pass - else: - out.append(str(c)) - return ''.join(out) - -if __name__ == '__main__': - if len(sys.argv) == 1: - sys.exit('Usage: %s filename\n' % sys.argv[0]) - for name in sys.argv[1:]: - plain_ascii = latin1_to_ascii(name) - if plain_ascii != name: - os.rename(name, plain_ascii) diff --git a/bin/smplay b/bin/smplay deleted file mode 100755 index 8561299..0000000 --- a/bin/smplay +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/sh - -(xscreensaver-command -exit -xset -dpms s off) & - -b="`basename $0`" - -if [ "$b" = smplay ]; then - GUI="-minigui" -elif [ "$b" = smplay-gui ]; then - GUI="-defaultgui" -else - echo "Bad script name, aborted" 1>&2 - exit 1 -fi - -cgmem_nice 500 smplayer "$GUI" "$@" -"$HOME"/admin/prog/audio-cdr-video/audio/pa-volume - -cd "$HOME" -xset +dpms s on -xscreensaver & diff --git a/bin/smplay-gui b/bin/smplay-gui deleted file mode 120000 index 8c13708..0000000 --- a/bin/smplay-gui +++ /dev/null @@ -1 +0,0 @@ -smplay \ No newline at end of file -- 2.39.2 From a9641b9731213a7d70247dcc46dcfc1c846df03b Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 25 Jan 2024 20:18:57 +0300 Subject: [PATCH 10/16] bin: Improve `compyle` Ignore error code. Exclude `tox` and virtual env directories. --- bin/compyle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/compyle b/bin/compyle index 4050467..da48caf 100755 --- a/bin/compyle +++ b/bin/compyle @@ -5,5 +5,5 @@ if [ -z "$1" ]; then exit 1 fi - python$PY_VER -m compileall "$@" && -exec python$PY_VER -O -m compileall "$@" + python$PY_VER -m compileall -x '\.tox/' -x '\.venv/' -x 'venv/' "$@" +exec python$PY_VER -O -m compileall -x '\.tox/' -x '\.venv/' -x 'venv/' "$@" -- 2.39.2 From 5520c0efb11271b663f813d236699c3c90ba02a1 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 25 Jan 2024 20:21:00 +0300 Subject: [PATCH 11/16] bin/git-open: Open browser window in private mode --- bin/git-open | 11 +++++++++-- bin/git-open-remote | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bin/git-open b/bin/git-open index b25e8d9..4cf5946 100755 --- a/bin/git-open +++ b/bin/git-open @@ -1,7 +1,12 @@ #! /bin/sh +if [ "x$1" = x-p ]; then + private="-p" + shift +fi + if [ $# -ne 1 ]; then - echo "Usage: git open url_key" >&2 + echo "Usage: git open [-p] url_key" >&2 exit 1 fi @@ -13,7 +18,9 @@ fi browser_section="`git config --get web.browser`" browser_cmd="`git config --get browser.\"$browser_section\".cmd`" -if [ -z "$browser_cmd" ]; then +if [ x"$private" = x-p ]; then + browser_cmd="webbrowser -p" +elif [ -z "$browser_cmd" ]; then browser_cmd="webbrowser -n" fi diff --git a/bin/git-open-remote b/bin/git-open-remote index 45c3a7e..9aa6a84 100755 --- a/bin/git-open-remote +++ b/bin/git-open-remote @@ -1,5 +1,10 @@ #! /bin/sh +if [ "x$1" = x-p ]; then + private="-p" + shift +fi + if [ -z "$1" ]; then branch="`git rev-parse --abbrev-ref HEAD`" remote="`git config --get branch.$branch.remote`" @@ -16,4 +21,4 @@ if [ -z "$remote" ]; then exit 1 fi -exec git-open remote.$remote.url +exec git-open $private remote.$remote.url -- 2.39.2 From 5cdb1217074fd86650a33c5e3fd7b605cae40d07 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 25 Jan 2024 20:21:40 +0300 Subject: [PATCH 12/16] bin: Fix `unzip.py` --- bin/unzip.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bin/unzip.py b/bin/unzip.py index dd0a79f..57af7b1 100755 --- a/bin/unzip.py +++ b/bin/unzip.py @@ -1,7 +1,7 @@ #! /usr/bin/env python3 """Unzip with encoded filenames - Written by Oleg Broytman. Copyright (C) 2009-2023 PhiloSoft Design. + Written by Oleg Broytman. Copyright (C) 2009-2024 PhiloSoft Design. """ import sys, os, time @@ -27,10 +27,9 @@ out = '.' for zinfo in zf.infolist(): path = zinfo.filename if isinstance(path, bytes): - path = path.decode('cp866') - recoded_path = path.encode(default_encoding) + recoded_path = path.decode('cp866').encode(default_encoding) else: - recoded_path = path.encode('cp437').decode('cp866') + recoded_path = path print(recoded_path) if path.startswith('./'): -- 2.39.2 From 4a9188e4539b6da57cfb3a85a0cd17babc0f70b5 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Sun, 28 Jan 2024 23:56:48 +0300 Subject: [PATCH 13/16] Feat(bin/cleanup-recode.sh): Default is the current directory --- bin/cleanup-recode.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cleanup-recode.sh b/bin/cleanup-recode.sh index 427cd6d..3f8213d 100755 --- a/bin/cleanup-recode.sh +++ b/bin/cleanup-recode.sh @@ -16,7 +16,7 @@ while getopts f:t: opt; do done shift `expr $OPTIND - 1` -for dir in "$@"; do +for dir in "${@:-.}"; do cleanup-filenames-recursive.sh "$dir" && recode-filenames-recursive.py "$from_enc" "$to_enc" "$dir" || exit 1 done -- 2.39.2 From 3ed5d7ea1f549b1073586fe155d7f6b572036bab Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 5 Feb 2024 19:22:50 +0300 Subject: [PATCH 14/16] .fvwmrc: Different way to blank screen using `xset dpms` --- .fvwm/main.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.fvwm/main.m4 b/.fvwm/main.m4 index 532cc44..8e7c740 100644 --- a/.fvwm/main.m4 +++ b/.fvwm/main.m4 @@ -866,7 +866,7 @@ AddToMenu Browsers "Choose one:" Title #+ "Blank" Exec exec xlock -mode blank AddToMenu XScreenSaverMenu "Choose mode:" Title -+ "Blank Screen via xset" Exec xset s on && exec xset s activate ++ "Blank Screen via xset" Exec xset dpms force off #+ "Blank Screen Now" Exec exec xscreensaver-command --suspend + "Activate A Hack Now" Exec exec xscreensaver-command --activate + "Lock Screen Now" Exec exec xscreensaver-command --lock -- 2.39.2 From 87e894e8ca4d76a9fb2746e68896be59395e78bb Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 9 Feb 2024 14:37:15 +0300 Subject: [PATCH 15/16] Add scripts to copy/move a file with recoded filename --- bin/cp_recode_fname | 40 ++++++++++++++++++++++++++++++++++++++++ bin/mv_recode_fname | 1 + 2 files changed, 41 insertions(+) create mode 100755 bin/cp_recode_fname create mode 120000 bin/mv_recode_fname diff --git a/bin/cp_recode_fname b/bin/cp_recode_fname new file mode 100755 index 0000000..8cae733 --- /dev/null +++ b/bin/cp_recode_fname @@ -0,0 +1,40 @@ +#! /bin/sh +set -e + +usage() { + echo "Usage: $0 [[from_enc] to_enc] filename" >&2 + exit 1 +} + +if [ $# -eq 1 ]; then + from_enc="`python3 -c \"from m_lib.defenc import default_encoding; print(default_encoding)"`" + if [ "$from_enc" != utf-8 ]; then + to_enc=utf-8 + else + usage + fi + filename="$1" +elif [ $# -eq 2 ]; then + from_enc="`python3 -c \"from m_lib.defenc import default_encoding; print(default_encoding)"`" + to_enc="$1" + filename="$2" +elif [ $# -eq 3 ]; then + from_enc="$1" + to_enc="$2" + filename="$3" +else + usage +fi + +cmd="`basename \"$0\"`" +case "$cmd" in + cp_*) cmd="cp -p" ;; + mv_*) cmd=mv ;; + *) + echo "Uncnown command $0, aborting" >&2 + exit 2 + ;; +esac + +filename_recoded=`echo "$filename" | iconv -f "$from_enc" -t "$to_enc"` +exec $cmd "$filename" "$filename_recoded" diff --git a/bin/mv_recode_fname b/bin/mv_recode_fname new file mode 120000 index 0000000..16052c7 --- /dev/null +++ b/bin/mv_recode_fname @@ -0,0 +1 @@ +cp_recode_fname \ No newline at end of file -- 2.39.2 From 370b05b5d682dffb13cf018d5bf8174bfbce0dfb Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Mon, 19 Feb 2024 23:11:34 +0300 Subject: [PATCH 16/16] Feat(recode-filenames-recursive): Allow to omit parameters --- bin/recode-filenames-recursive.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/bin/recode-filenames-recursive.py b/bin/recode-filenames-recursive.py index b7787e4..5408563 100755 --- a/bin/recode-filenames-recursive.py +++ b/bin/recode-filenames-recursive.py @@ -1,14 +1,34 @@ #! /usr/bin/env python3 import sys, os -from recode_filenames import _recode -if len(sys.argv) == 3: +from m_lib.defenc import default_encoding + +if len(sys.argv) == 1: + src_encoding = default_encoding + if src_encoding == 'utf-8': + sys.exit("Usage: %s [[src_enc] dst_enc [start_dir]]" % sys.argv[0]) + else: + dst_encoding = 'utf-8' + start_dir = '.' +elif len(sys.argv) == 2: + src_encoding = default_encoding + dst_encoding = sys.argv[1] start_dir = '.' +elif len(sys.argv) == 3: + src_encoding = default_encoding + dst_encoding = sys.argv[1] + start_dir = sys.argv[2] elif len(sys.argv) == 4: + src_encoding = sys.argv[1] + dst_encoding = sys.argv[2] start_dir = sys.argv[3] else: - sys.exit("Usage: %s src_enc dst_enc [start_dir]" % sys.argv[0]) + sys.exit("Usage: %s [[src_enc] dst_enc [start_dir]]" % sys.argv[0]) + +# Fake for recode_filenames.py +sys.argv = ['', src_encoding, dst_encoding] +from recode_filenames import _recode def _onerror(exc): -- 2.39.2