]> git.donarmstrong.com Git - bin.git/commitdiff
add script to remove empty i3 workspaces master
authorDon Armstrong <don@donarmstrong.com>
Thu, 19 Jun 2025 21:34:38 +0000 (14:34 -0700)
committerDon Armstrong <don@donarmstrong.com>
Thu, 19 Jun 2025 21:34:38 +0000 (14:34 -0700)
aws_run_as [new file with mode: 0755]
i3_remove_empty_workspaces [new file with mode: 0755]
new_home_directory
reset_usb_bus [new file with mode: 0755]

diff --git a/aws_run_as b/aws_run_as
new file mode 100755 (executable)
index 0000000..01be0cb
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Borrowed and modified from https://stackoverflow.com/questions/63241009/aws-sts-assume-role-in-one-command
+
+ROLE_ARN=$1
+
+shift
+
+export $(printf "AWS_ACCESS_KEY_ID=%s AWS_SECRET_ACCESS_KEY=%s AWS_SESSION_TOKEN=%s" \
+          $(aws sts assume-role --role-arn "$ROLE_ARN" --role-session-name "${SESSION_NAME:-aws_run_as}" \
+            --query "Credentials.[AccessKeyId,SecretAccessKey,SessionToken]" \
+            --output text))
+exec "$@"
diff --git a/i3_remove_empty_workspaces b/i3_remove_empty_workspaces
new file mode 100755 (executable)
index 0000000..b1969d3
--- /dev/null
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+focused_workspace=$(i3-msg -t get_workspaces|jq '.[map(.focused == true) | index(true)]["num"]')
+
+for a in $(i3-msg -t get_workspaces|jq '.[]["num"]'); do
+    i3-msg -q "workspace $a"
+done;
+
+i3-msg -q "workspace ${focused_workspace}" 
index 3e492a37c7da0ff6bf9a4fc72a2349f38b44a489..260d2af88386eb75f4861dc3e39da96ef21df259 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-# wget -O new_home_directory 'http://git.donarmstrong.com/?p=bin.git;a=blob_plain;f=new_home_directory;hb=HEAD'
+# wget -O new_home_directory 'https://git.donarmstrong.com/?p=bin.git;a=blob_plain;f=new_home_directory;hb=HEAD'
 # sh new_home_directory;
 
 
@@ -19,7 +19,7 @@ for pkg in mr vcsh; do
         mkdir -p local_packages/$pkg;
         (cd local_packages/$pkg;
          deb_name=$pkg
-         if [ $pkg == "mr"; ]; then
+         if [ $pkg = "mr" ]; then
              deb_name=myrepos
          fi;
          if which apt-get >/dev/null 2>&1; then
@@ -27,10 +27,10 @@ for pkg in mr vcsh; do
              dpkg-deb -x ${deb_name}*.deb .
          else
              # ok, this host isn't Debian.
-             if [ "$pkg" == "mr" ]; then
+             if [ "$pkg" = "mr" ]; then
                  wget http://http.debian.net/debian/pool/main/m/myrepos/myrepos_1.20160123_all.deb
                  ar p myrepos*.deb data.tar.xz|xz --decompress|tar -x
-             elif [ "$pkg" == "vcsh" ]; then
+             elif [ "$pkg" = "vcsh" ]; then
                  wget http://http.debian.net/debian/pool/main/v/vcsh/vcsh_1.20151229-1_all.deb
                  ar p vcsh*.deb data.tar.xz|xz --decompress|tar -x
              fi;
@@ -39,8 +39,8 @@ for pkg in mr vcsh; do
         );
         mkdir -p bin
         ln ~/local_packages/$pkg/usr/bin/$pkg bin/$pkg -s
-        if [ "$pkg" == "mr" ]; then
-            echo -e "[DEFAULT]\ninclude = cat ~/local_packages/$pkg/usr/share/mr/*" >> ~/.mrconfig
+        if [ "$pkg" = "mr" ]; then
+            printf '[DEFAULT]\ninclude = cat ~/local_packages/%s/usr/share/mr/*' "$pkg" >> ~/.mrconfig
         fi;
         PATH="$HOME/local_packages/$pkg/usr/bin/:$PATH"
         export PATH
diff --git a/reset_usb_bus b/reset_usb_bus
new file mode 100755 (executable)
index 0000000..590e51d
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+for i in /sys/bus/pci/drivers/[uoex]hci_hcd/*:*; do
+  [ -e "$i" ] || continue
+  echo "${i##*/}" > "${i%/*}/unbind"
+  echo "${i##*/}" > "${i%/*}/bind"
+done