Bryan Roessler 2 тижнів тому
батько
коміт
0f39557047

+ 3 - 2
.gitignore

@@ -1,4 +1,5 @@
 .vscode/
-setup/
 .old/
-jriver
+jriver/
+secrets/
+.env

+ 171 - 5
LICENSE

@@ -1,8 +1,174 @@
-MIT License
-Copyright (c) <year> <copyright holders>
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
 
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
 
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+1. Definitions.
 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+   "License" shall mean the terms and conditions for use, reproduction,
+   and distribution as defined by Sections 1 through 9 of this document.
+
+   "Licensor" shall mean the copyright owner or entity authorized by
+   the copyright owner that is granting the License.
+
+   "Legal Entity" shall mean the union of the acting entity and all
+   other entities that control, are controlled by, or are under common
+   control with that entity. For the purposes of this definition,
+   "control" means (i) the power, direct or indirect, to cause the
+   direction or management of such entity, whether by contract or otherwise,
+   or (ii) ownership of fifty percent (50%) or more of the outstanding shares,
+   or (iii) beneficial ownership of such entity.
+
+   "You" (or "Your") shall mean an individual or Legal Entity exercising
+   permissions granted by this License.
+
+   "Source" form shall mean the preferred form for making modifications,
+   including but not limited to software source code, documentation source,
+   and configuration files.
+
+   "Object" form shall mean any form resulting from mechanical transformation
+   or translation of a Source form, including but not limited to compiled
+   object code, generated documentation, and conversions to other media types.
+
+   "Work" shall mean the work of authorship, whether in Source or Object form,
+   made available under the License, as indicated by a copyright notice
+   that is included in or attached to the work (an example is provided in the
+   Appendix below).
+
+   "Derivative Works" shall mean any work, whether in Source or Object form,
+   that is based on (or derived from) the Work and for which the editorial
+   revisions, annotations, elaborations, or other modifications represent, as
+   a whole, an original work of authorship. For the purposes of this License,
+   Derivative Works shall not include works that remain separable from, or
+   merely link (or bind by name) to the interfaces of, the Work and Derivative
+   Works thereof.
+
+   "Contribution" shall mean any work of authorship, including the original
+   version of the Work and any modifications or additions to that Work or
+   Derivative Works thereof, that is intentionally submitted to Licensor for
+   inclusion in the Work by the copyright owner or by an individual or Legal
+   Entity authorized to submit on behalf of the copyright owner. For the
+   purposes of this definition, "submitted" means any form of electronic,
+   verbal, or written communication sent to the Licensor or its representatives,
+   including but not limited to communication on electronic mailing lists,
+   source code control systems, and issue tracking systems that are managed by,
+   or on behalf of, the Licensor for the purpose of discussing and improving the
+   Work, but excluding communication that is conspicuously marked or otherwise
+   designated in writing by the copyright owner as "Not a Contribution."
+
+   "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
+   of whom a Contribution has been received by Licensor and subsequently
+   incorporated within the Work.
+
+2. Grant of License.
+
+   Subject to the terms and conditions of this License, each Contributor hereby
+   grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
+   irrevocable (except as stated in this section) patent license to make, have made,
+   use, offer to sell, sell, import, and otherwise transfer the Work, where such
+   license applies only to those patent claims licensable by such Contributor that
+   are necessarily infringed by their Contribution(s) alone or by combination of
+   their Contribution(s) with the Work to which such Contribution(s) was submitted.
+   If You institute patent litigation against any entity (including a cross-claim or
+   counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated
+   within the Work constitutes direct or contributory patent infringement, then any
+   patent licenses granted to You under this License for that Work shall terminate
+   as of the date such litigation is filed.
+
+3. Redistribution.
+
+   You may reproduce and distribute copies of the Work or Derivative Works thereof in
+   any medium, with or without modifications, and in Source or Object form, provided
+   that You meet the following conditions:
+
+      (a) You must give any other recipients of the Work or Derivative Works a copy of
+          this License; and
+
+      (b) You must cause any modified files to carry prominent notices stating that You
+          changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works that You distribute,
+          all copyright, patent, trademark, and attribution notices from the Source form
+          of the Work, excluding those notices that do not pertain to any part of the
+          Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its distribution, then any
+          Derivative Works that You distribute must include a readable copy of the
+          attribution notices contained within such NOTICE file, excluding those notices
+          that do not pertain to any part of the Derivative Works, in at least one of the
+          following places: within a NOTICE text file distributed as part of the Derivative
+          Works; within the Source form or documentation, if provided along with the
+          Derivative Works; or, within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents of the NOTICE file
+          are for informational purposes only and do not modify the License. You may add Your
+          own attribution notices within Derivative Works that You distribute, alongside or
+          as an addendum to the NOTICE text from the Work, provided that such additional
+          attribution notices cannot be construed as modifying the License.
+
+4. Submission of Contributions.
+
+   Unless You explicitly state otherwise, any Contribution intentionally submitted for
+   inclusion in the Work by You to the Licensor shall be under the terms and conditions
+   of this License, without any additional terms or conditions. Notwithstanding the above,
+   nothing herein shall supersede or modify the terms of any separate license agreement you
+   may have executed with Licensor regarding such Contributions.
+
+5. Trademarks.
+
+   This License does not grant permission to use the trade names, trademarks, service marks, or
+   product names of the Licensor, except as required for describing the origin of the Work and
+   reproducing the content of the NOTICE file.
+
+6. Disclaimer of Warranty.
+
+   Unless required by applicable law or agreed to in writing, Licensor provides the Work
+   (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES
+   OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any
+   warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+   PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using
+   or redistributing the Work and assume any risks associated with Your exercise of permissions
+   under this License.
+
+7. Limitation of Liability.
+
+   In no event and under no legal theory, whether in tort (including negligence), contract,
+   or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts)
+   or agreed to in writing, shall any Contributor be liable to You for damages, including any
+   direct, indirect, special, incidental, or consequential damages of any character arising as a
+   result of this License or out of the use or inability to use the Work (including but not limited
+   to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all
+   other commercial damages or losses), even if such Contributor has been advised of the possibility
+   of such damages.
+
+8. Accepting Warranty or Additional Liability.
+
+   While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a
+   fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or services.
+   However, in accepting such obligations, You may act only on Your own behalf and on Your sole
+   responsibility, not on behalf of any Contributor, and only if You agree to indemnify, defend, and
+   hold each Contributor harmless for any liability incurred by, or claims asserted against, such
+   Contributor by reason of your accepting any such warranty or additional liability.
+
+9. Miscellaneous.
+
+   This License represents the complete agreement concerning the subject matter herein and
+   supersedes all prior agreements or understandings, whether written or oral, relating to the subject
+   matter of this License. If any provision of this License is held to be unenforceable, such provision
+   shall be reformed only to the extent necessary to make it enforceable. Any failure to enforce any
+   provision of this License shall not constitute a waiver of such provision. This License does not,
+   and shall not be, construed as granting any rights to use the trademarks, service marks, or logos of
+   the Licensor except as expressly stated herein.
+
+   Each Contributor's rights under this License shall terminate automatically if You breach any of the
+   terms and conditions of this License. However, this License will terminate Your rights only
+   for the specific Contributions affected by such a breach.
+
+   If You bring a claim for patent infringement against any entity (including a cross-claim or counterclaim
+   in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct
+   or contributory patent infringement, then any patent licenses granted to You under this License for
+   that Work shall terminate as of the date such litigation is filed.
+
+   Sections 1 through 9 shall survive termination of this License.
+
+                              END OF TERMS AND CONDITIONS

+ 4 - 2
README.md

@@ -1,3 +1,5 @@
-# scripts
+---
 
-Some scripts you may find useful
+Some scripts you may find useful.
+
+Deploy scripts using GNU stow: `stow -R --adopt -t "$HOME" shell python`

+ 0 - 0
git/hooks-post-receive-push-to-gh.sh → git/hooks/hooks-post-receive-push-to-gh.sh


+ 0 - 49
jriver/jriver-fix-date-imported.py

@@ -1,49 +0,0 @@
-#!/usr/bin/env python3
-
-import sys
-import os
-from pathlib import PureWindowsPath
-
-in_file = sys.argv[1]
-out_file = sys.argv[2]
-
-def getAlbumPath(line):
-    filename = line.lstrip('<Field Name="Filename">')
-    filename = filename.rstrip('</Field>\n')
-    path = PureWindowsPath(filename)
-    path = path.parents[0]
-    return str(path)
-
-def getDate(line):
-    date = line.lstrip('<Field Name="Date Imported">')
-    date = date.rstrip('</Field>\n')
-    return int(date)
-
-
-f = open(in_file, "r")
-lines = f.readlines()
-f.close()
-
-albums = {}
-for lnum,line in enumerate(lines):
-    if '<Field Name="Filename">' in line:
-        album = getAlbumPath(line)
-    elif '<Field Name="Date Imported">' in line:
-        date = getDate(line)
-        if album in albums:
-            albums[album].append((lnum, date))
-        else:
-            albums[album] = [(lnum, date)]
-
-earliest = {}
-for album in albums:
-    tracks = albums[album]
-    earliest_date = min(tracks, key = lambda t: t[1])[1]
-    for track in tracks:
-        lines[track[0]] = f'<Field Name="Date Imported">{earliest_date}</Field>\n'
-
-f = open(out_file, 'w')
-f_string = "".join(lines)
-f.write(f_string)
-f.close()
-exit()

+ 0 - 37
jriver/jriver-replace-date-imported.py

@@ -1,37 +0,0 @@
-#!/usr/bin/env python3
-
-import sys
-import os
-
-in_file = sys.argv[1]
-out_file = sys.argv[2]
-
-def getImportDate(line):
-    date = line.lstrip('<Field Name="Date Imported">')
-    date = date.rstrip('</Field>\n')
-    return int(date)
-
-def getCreateDate(line):
-    date = line.lstrip('<Field Name="Date Modified">')
-    date = date.rstrip('</Field>\n')
-    return int(date)
-
-f = open(in_file, "r")
-lines = f.readlines()
-f.close()
-
-for lnum,line in enumerate(lines):
-    if '<Field Name="Date Imported">' in line:
-        import_date = getImportDate(line)
-        date_imported_line = lnum
-    elif '<Field Name="Date Modified">' in line:
-        create_date = getCreateDate(line)
-        if create_date < import_date:
-            print(import_date, create_date)
-            lines[date_imported_line] = f'<Field Name="Date Imported">{create_date}</Field>\n'    
-
-f = open(out_file, 'w')
-f_string = "".join(lines)
-f.write(f_string)
-f.close()
-exit()

+ 0 - 3
jriver/jriverexpressions.txt

@@ -1,3 +0,0 @@
-IfElse(IsEqual([Media Type], Audio), If(IsEqual([Media Sub Type], Podcast), podcasts/Clean([Album],3), music/RemoveCharacters(Clean([Album Artist (auto)],3),.,2)/[[Year]] RemoveCharacters(Clean([Album],3),.,3)), IsEqual([Media Sub Type], Movie), movies/Clean(RemoveCharacters([Name],:), 3) [[Year]], IsEqual([Media Sub Type], TV Show), tv/Clean([Series],3)/Season PadNumber([Season], 2))
-
-IfElse(IsEqual([Media Type], Audio), If(IsEmpty([Disc #],1), 1[Track #], [Disc #][Track #]) - RemoveCharacters(Clean([Artist] - [Name],3),.,3), IsEqual([Media Sub Type], Movie), Clean(RemoveCharacters([Name],:),3) [[Year]], IsEqual([Media Sub Type], TV Show), Clean([Series] - S[Season]E[Episode] - [Name],3))

+ 0 - 0
python/remove-music-dirs-with-just-image → python/.local/bin/remove-music-dirs-with-just-image


+ 0 - 0
shell/btrfs-convert → shell/.local/bin/btrfs-convert


+ 0 - 0
shell/chroot-rescue → shell/.local/bin/chroot-rescue


+ 0 - 0
shell/container-home-assistant → shell/.local/bin/container-home-assistant


+ 0 - 0
shell/dotfiles-store → shell/.local/bin/dotfiles-store


+ 0 - 0
shell/extract → shell/.local/bin/extract


+ 0 - 0
shell/history-clean → shell/.local/bin/history-clean


+ 0 - 0
shell/iso-to-mkv → shell/.local/bin/iso-to-mkv


+ 6 - 4
shell/prunefiles → shell/.local/bin/prune-files

@@ -1,15 +1,17 @@
 #!/usr/bin/env bash
 # Remove all but the latest N versions of files matching given prefixes
-# See prunefiles --help for usage
+# Usage: prune-files -k 3 thisfileprefix [thatfileprefix]
+# Copyright 2021-2025 Bryan C. Roessler
+# Licensed under the Apache License, Version 2.0
 
-prunefiles() {
+prune-files() {
   declare -ag PREFIXES
   declare -g KEEP_INT=1 # default number of files to keep
 
   printHelpAndExit() {
     cat <<-'EOF'
 			USAGE:
-			  prunefiles -k 3 thisfileprefix [thatfileprefix]
+			  prune-files -k 3 thisfileprefix [thatfileprefix]
 
 			OPTIONS:
 			  -k, --keep NUMBER
@@ -65,6 +67,6 @@ prunefiles() {
 
 # Allow script to be safely sourced
 if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
-  prunefiles "$@"
+  prune-files "$@"
   exit $?
 fi

+ 0 - 0
shell/random-words → shell/.local/bin/random-words


+ 0 - 0
shell/remove-small-dirs → shell/.local/bin/remove-small-dirs


+ 96 - 0
shell/.local/bin/setup-laptop.sh

@@ -0,0 +1,96 @@
+#!/usr/bin/env bash
+# Fedora 41 setup script
+
+# Get some OS details
+# [[ -e /etc/os-release ]] && source /etc/os-release
+
+# Add external repos
+sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:zsh-users:zsh-completions/Fedora_Rawhide/shells:zsh-users:zsh-completions.repo
+sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
+sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
+
+# Add/remove packages
+sudo dnf remove -y abrt rhythmbox gnome-software spice-vdagent open-vm-tools-desktop orca anaconda-live gnome-initial-setup
+sudo dnf install -y \
+       rpmfusion-free-release \
+       zsh zsh-completions ShellCheck \
+       btrbk btrfsmaintenance \
+       vim htop remmina calibre pinta toolbox code gnome-tweaks \
+       wl-clipboard syncthing profile-sync-daemon \
+       python3-virtualenv python3-virtualenvwrapper nautilus-python gettext \
+       setroubleshoot
+        
+# Use zsh as default shell
+chsh -s "$(which zsh)"
+
+# Enable profile-sync-daemon for the user
+systemctl --user enable --now psd
+
+# Enable automatic system updates
+sudo systemctl enable --now dnf5-automatic.timer
+
+# Make btrfs subvolumes
+sudo btrfs sub create ~/media/music
+sudo btrfs sub create ~/media/tv
+sudo btrfs sub create ~/media/pictures
+sudo btrfs sub create ~/media/ebooks
+sudo btrfs sub create ~/media/movies
+sudo btrfs sub create ~/media/podcasts
+
+# Create links
+ln -s ~/media/music ~/music
+ln -s ~/documents/develop ~/develop
+ln -s ~/.local/bin ~/bin
+ln -s ~/devices/phone/podcasts ~/media/podcasts
+ln -s ~/develop/scripts/share-link ~/.local/share/nautilus/scripts/
+
+# Allow some commands to invoke sudo without a password
+echo "bryan ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper, /usr/sbin/btrfs, /usr/bin/journalctl, /usr/bin/dnf, /usr/bin/fwupdmgr, /usr/bin/dmesg" | sudo tee -a /etc/sudoers > /dev/null
+
+# Use full location in nautilus
+gsettings set org.gnome.nautilus.preferences always-use-location-entry true
+
+# Increase scrollback limit for gnome-console
+kgx --set-scrollback 100000000
+
+# btrbk
+# sudo ln -s ~/.config/btrbk/btrbk.conf /etc/btrbk/btrbk.conf
+# ssh-keygen -t ed25519 -f ~/.config/btrbk/id_ed25519
+#[[ ! -d "/etc/btrbk/ssh/" ]] && sudo mkdir -p /etc/btrbk/ssh
+#sudo ln -s ~/.config/btrbk/id_ed25519 /etc/btrbk/ssh/id_ed25519
+
+# Firefox
+# mousewheel.acceleration.factor 20
+# mousewheel.acceleration.start 2
+# gfx.webrender.all true
+# browser.tabs.insertAfterCurrent true
+# browser.ctrlTab.sortByRecentlyUsed = true
+
+# Create battery charging threshold service
+sudo bash -c "cat <<-EOF > /etc/systemd/system/set-battery-charge-threshold.service
+       [Unit]
+       Description=Set battery charge thresholds
+       After=multi-user.target
+       StartLimitBurst=0
+
+       [Service]
+       Type=oneshot
+       Restart=on-failure
+       RemainAfterExit=yes
+       ExecStart=/bin/bash -c 'echo 80 > /sys/class/power_supply/BAT0/charge_control_start_threshold; echo 90 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
+       ExecStop=/bin/bash -c 'echo 100 > /sys/class/power_supply/BAT0/charge_control_end_threshold; echo 99 > /sys/class/power_supply/BAT0/charge_control_start_threshold'
+
+       [Install]
+       WantedBy=multi-user.target
+EOF"
+sudo systemctl daemon-reload &&
+sudo systemctl enable --now set-battery-charge-threshold.service
+
+# Increase max_user_watches for VSCode
+echo "fs.inotify.max_user_watches=524288" | sudo tee /etc/sysctl.d/local.conf > /dev/null
+sudo systemctl restart systemd-sysctl.service
+
+# Install clone dirs
+git -C ~/.local/bin clone https://git.bryanroessler.com/bryan/installJRMC.git -b dev
+git -C ~/.local/bin clone https://git.bryanroessler.com/bryan/openwrtbuilder.git -b dev
+

+ 0 - 0
shell/share-link → shell/.local/bin/share-link


+ 0 - 0
shell/speedtest-compare → shell/.local/bin/speedtest-compare


+ 0 - 0
shell/ssh-wrap → shell/.local/bin/ssh-wrap


+ 0 - 0
shell/strip-exif → shell/.local/bin/strip-exif


+ 0 - 0
shell/thinkpad-enable-trackpoint-scrolling → shell/.local/bin/thinkpad-enable-trackpoint-scrolling


+ 0 - 0
shell/tmux-management → shell/.local/bin/tmux-management


+ 0 - 0
shell/tree-to-markdown → shell/.local/bin/tree-to-markdown


+ 0 - 0
shell/update-git-hooks → shell/.local/bin/update-git-hooks