From 5ad0cc56f3dbc5a14484cb5547472349bb99a889 Mon Sep 17 00:00:00 2001 From: EnricoGuccii Date: Sun, 3 May 2026 02:10:07 +0200 Subject: add: scripts --- scripts/anki.sh | 25 +++++++++++++++++++++++++ scripts/scripts_menu.sh | 9 +++++++++ scripts/test.sh | 3 +++ scripts/toggle_external_monitor.sh | 19 +++++++++++++++++++ scripts/toggle_internal_monitor.sh | 17 +++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100755 scripts/anki.sh create mode 100755 scripts/scripts_menu.sh create mode 100755 scripts/test.sh create mode 100755 scripts/toggle_external_monitor.sh create mode 100644 scripts/toggle_internal_monitor.sh (limited to 'scripts') diff --git a/scripts/anki.sh b/scripts/anki.sh new file mode 100755 index 0000000..f592b6c --- /dev/null +++ b/scripts/anki.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +NEW=$(curl -s http://127.0.0.1:8765 -H "Content-Type: application/json" -d '{ + "action":"findCards", + "version":6, + "params":{ + "query":"is:new" + } +}') + +DUE=$(curl -s http://127.0.0.1:8765 -H "Content-Type: application/json" -d '{ + "action": "findCards", + "version": 6, + "params": { + "query": "is:due" + } +}') + +DONE=$(curl -s http://127.0.0.1:8765 -H "Content-Type: application/json" -d '{ + "action": "getNumCardsReviewedToday", + "version": 6 +}') + + +echo "new:$(echo $NEW | jq '.result | length') due:$(echo $DUE | jq '.result | length') done:$(echo $DONE | jq '.result')" diff --git a/scripts/scripts_menu.sh b/scripts/scripts_menu.sh new file mode 100755 index 0000000..881cc00 --- /dev/null +++ b/scripts/scripts_menu.sh @@ -0,0 +1,9 @@ +#!/bin/zsh + +dir="$HOME/scripts" + +selected=$(find "$dir" -maxdepth 1 -type f -printf "%f\n" | wmenu -f "JetBrainsMonoNF 10" -N "#121212" -s "#121212" -S "#7162ac" -M "#121212" -l 5 -i -p "Run script: ") + +if [[ -n "$selected" ]]; then + zsh "$dir/$selected" +fi diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100755 index 0000000..cc4c775 --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,3 @@ +#!/bin/zsh + +notify-send "test" diff --git a/scripts/toggle_external_monitor.sh b/scripts/toggle_external_monitor.sh new file mode 100755 index 0000000..f2e1a59 --- /dev/null +++ b/scripts/toggle_external_monitor.sh @@ -0,0 +1,19 @@ +#!/bin/zsh + +INTERNAL="eDP-1" +EXTERNAL="HDMI-A-1" + +outputs=$(swaymsg -t get_outputs -r) + +internal_active=$(echo "$outputs" | jq -r --arg o "$INTERNAL" '.[] | select(.name==$o and .active==true) | .name') +external_active=$(echo "$outputs" | jq -r --arg o "$EXTERNAL" '.[] | select(.name==$o and .active==true) | .name') + +if [[ -n "$internal_active" ]]; then + if [[ -n "$external_active" ]]; then + swaymsg output "$EXTERNAL" disable + else + swaymsg output "$EXTERNAL" enable + fi +fi + + diff --git a/scripts/toggle_internal_monitor.sh b/scripts/toggle_internal_monitor.sh new file mode 100644 index 0000000..706dcf1 --- /dev/null +++ b/scripts/toggle_internal_monitor.sh @@ -0,0 +1,17 @@ +#!/bin/zsh + +INTERNAL="eDP-1" +EXTERNAL="HDMI-A-1" + +outputs=$(swaymsg -t get_outputs -r) + +internal_active=$(echo "$outputs" | jq -r --arg o "$INTERNAL" '.[] | select(.name==$o and .active==true) | .name') +external_active=$(echo "$outputs" | jq -r --arg o "$EXTERNAL" '.[] | select(.name==$o and .active==true) | .name') + +if [[ -n "$external_active" ]]; then + if [[ -n "$internal_active" ]]; then + swaymsg output "$INTERNAL" disable + else + swaymsg output "$INTERNAL" enable + fi +fi -- cgit v1.2.3