浏览代码

Update scripts

Bryan Roessler 1 周之前
父节点
当前提交
35902718e3
共有 5 个文件被更改,包括 56 次插入28 次删除
  1. 14 11
      nautilus/.local/share/nautilus/scripts/share-link
  2. 1 0
      powershell/activate-windows.ps1
  3. 11 0
      python/qr-generate
  4. 17 0
      scripts.code-workspace
  5. 13 17
      shell/.local/bin/extract

+ 14 - 11
shell/.local/bin/share-link → nautilus/.local/share/nautilus/scripts/share-link

@@ -13,23 +13,26 @@ if [[ "$#" -lt 1 ]]; then
 	exit 1
 fi
 
-hash wl-copy &>/dev/null || echo "Please install wl-copy (usually in the wl-clipboard package)"
+hash wl-copy &>/dev/null || { echo "Please install wl-copy"; exit 1; }
+hash rsync &>/dev/null || { echo "Please install rsync"; exit 1; }
 
 if [[ -v NAUTILUS_SCRIPT_SELECTED_URIS ]]; then
 	readarray -t files <<< "$NAUTILUS_SCRIPT_SELECTED_URIS"
-	files=("${files[@]#file://}")
-	files=("${files[@]//\%20/ }")
+	for f in "${files[@]}"; do
+		f="${f#file://}"
+		f="${f//\%20/ }"
+		fixed_files+=("$f")
+	done
 else
-	files=("$@")
+	fixed_files=("$@")
 fi
 
-for file in "${files[@]}"; do
-	[[ "$file" == "" ]] && continue
-	echo here
-    fname="${file##*/}"
-    random64=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 64 | head -n 1)
-	echo "rsync -a ${file} ${ssh_server}:${ssh_files_path}/${random64}/"
-	nohup rsync -a "${file}" "${ssh_server}:${ssh_files_path}/${random64}/" &
+links_array=()
+for f in "${fixed_files[@]}"; do
+	[[ "$f" == "" ]] && continue
+	fname="${f##*/}"
+	random64=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 64 | head -n 1)
+	nohup rsync -a "$f" "${ssh_server}:${ssh_files_path}/${random64}/" &
 	links_array+=("$www_files_path/${random64}/${fname// /%20}")
 done
 

+ 1 - 0
powershell/activate-windows.ps1

@@ -0,0 +1 @@
+irm https://get.activated.win | iex

+ 11 - 0
python/qr-generate

@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+import qrcode
+
+address = "bc1q7wy0kszjavgcrvkxdg7mf3s6rh506rasnhfa4a"
+label = "Bryan C. Roessler"
+message = "Thanks for your donation"
+
+uri = f"bitcoin:{address}&label={label}&message={message}"
+
+qr = qrcode.make(uri)
+qr.save("bitcoin_qr.png")

+ 17 - 0
scripts.code-workspace

@@ -0,0 +1,17 @@
+{
+	"folders": [
+		{
+			"name": "scripts",
+			"path": "."
+		},
+		{
+			"name": "dotfiles",
+			"path": "../dotfiles"
+		},
+		{
+			"name": "hartmanlab",
+			"path": "../hartmanlab"
+		}
+	],
+	"settings": {}
+}

+ 13 - 17
shell/.local/bin/extract

@@ -2,26 +2,22 @@
 # Unzip most filetypes automatically
 
 extract() {
+  local a
   [[ $# -eq 0 ]] && { echo "usage: extract <archive...>" >&2; return 1; }
   for a in "$@"; do
     [[ ! -f $a ]] && { echo "$a: not a file" >&2; continue; }
     case $a in
-      *.tar.bz2|*.tbz2) tar xvjf "$a" ;;
-      *.tar.gz|*.tgz)   tar xvzf "$a" ;;
-      *.tar.xz)         tar --xz -xvf "$a" ;;
-      *.tar.zst)        tar --use-compress-program=unzstd -xvf "$a" ;;
-      *.tar.lz)         tar --lzip -xvf "$a" ;;
-      *.tar)            tar xvf "$a" ;;
-      *.bz2)            bunzip2 "$a" ;;
-      *.gz)             gunzip "$a" ;;
-      *.xz)             unxz "$a" ;;
-      *.zst)            unzstd "$a" ;;
-      *.lz)             unlz "$a" ;;
-      *.zip)            unzip "$a" ;;
-      *.rar)            unrar x "$a" ;;
-      *.7z)             7z x "$a" ;;
-      *.Z)              uncompress "$a" ;;
-      *)                echo "$a: cannot extract" ;;
+      *.tar.*|*.tgz|*.tbz2) tar xvf "$a" --auto-compress ;;
+      *.tar)                tar xvf "$a" ;;
+      *.gz)                 gunzip "$a" ;;
+      *.bz2)                bunzip2 "$a" ;;
+      *.xz)                 unxz "$a" ;;
+      *.zst)                unzstd "$a" ;;
+      *.zip)                unzip "$a" ;;
+      *.rar)                unrar x "$a" ;;
+      *.7z)                 7z x "$a" ;;
+      *.Z)                  uncompress "$a" ;;
+      *)                    echo "$a: cannot extract" ;;
     esac
   done
 }
@@ -29,5 +25,5 @@ extract() {
 # Allow script to be safely sourced
 if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
 	extract "$@"
-	exit $?
+	exit
 fi