commit f8130bd7d0a47e65716e82d5e5f477e4f7ed357e Author: lucca Date: Thu Jun 11 13:47:48 2026 -0400 added scripts folder to gitea diff --git a/.swp b/.swp new file mode 100644 index 0000000..1ebb8be Binary files /dev/null and b/.swp differ diff --git "a/\\" "b/\\" new file mode 100644 index 0000000..ac1ba69 --- /dev/null +++ "b/\\" @@ -0,0 +1,44 @@ +#!/bin/bash + +# Quest 2 wireless mirror to PC → 480i CRT +# Right-eye focus crop + audio kept on Quest (no mute) + +IP="10.0.0.30:5555" + +echo "Enabling ADB over TCP..." +adb tcpip 5555 +sleep 2 + +echo "Connecting to Quest..." +adb connect "${IP}" + +echo "" +echo "ADB devices (should list your Quest):" +adb devices + +echo "" +read -p "Disconnect USB now. Wake Quest fully (put it on), launch game/app, press Enter..." + +echo "" +echo "Starting scrcpy... (fullscreen with F11 or similar; q/Ctrl+C to quit)" +echo "" + +scrcpy -s "${IP}" \ + --crop=1832:960:1832:0 \ + --max-size=640 \ + --max-fps=30 \ + --video-bit-rate=800K \ + --no-control \ + --always-on-top \ + --window-width=640 \ + --window-height=480 \ + --window-borderless + +echo "" +echo "Troubleshooting:" +echo " - Still seeing both eyes/duplication? Increase x-offset: try --crop=1832:960:1850:100 or --crop=1832:960:1900:0" +echo " - Right eye looks wrong/black? Swap to left: --crop=1832:960:0:0 (or tweak offset lower like 100:100)" +echo " - Black screen overall? Add --encoder=OMX.google.h264.encoder" +echo " - No audio on Quest? (rare) — audio should play normally in headset; scrcpy captures to PC too unless --no-audio is added" +echo " - Game lag? Lower --video-bit-rate=500K or --max-size=480" +echo " - HDMI from PC → composite adapter → CRT" diff --git a/__pycache__/vidModeFunctions.cpython-312.pyc b/__pycache__/vidModeFunctions.cpython-312.pyc new file mode 100644 index 0000000..f3bbdce Binary files /dev/null and b/__pycache__/vidModeFunctions.cpython-312.pyc differ diff --git a/alttab.sh b/alttab.sh new file mode 100755 index 0000000..becc5b3 --- /dev/null +++ b/alttab.sh @@ -0,0 +1,19 @@ +#!/bin/bash +mousewarp () +{ +HERE="$(xdotool getwindowfocus)" +ULX=$(xwininfo -id "$HERE" | grep " Absolute upper-left X:" | awk '{print $4}') +ULY=$(xwininfo -id "$HERE" | grep " Absolute upper-left Y:" | awk '{print $4}') + +# If there is no window, ULX == 1 and ULY == 1. +if [ "$ULX" != "-1" ] || [ "$ULY" != "-1" ]; then + eval "$(xdotool getwindowgeometry --shell "$HERE")" + + ((NX="$WIDTH"/2)) + ((NY="$HEIGHT"/2)) + + xdotool mousemove --window "$WINDOW" "$NX" "$NY" +fi +} +rofi -show window -show-icons +mousewarp diff --git a/binary-to-text.sh b/binary-to-text.sh new file mode 100755 index 0000000..ac35433 --- /dev/null +++ b/binary-to-text.sh @@ -0,0 +1,10 @@ +#!/bin/bash +BINARY="01001000 01100101 01101100 01101100 01101111" +binaryToText() { +while read line +do +echo -n "\x$(echo obase=16\;ibase=2\;$line | bc)" +done +} +echo $BINARY | binaryToText + diff --git a/clipboardBufferData.pk b/clipboardBufferData.pk new file mode 100644 index 0000000..f32d9b7 Binary files /dev/null and b/clipboardBufferData.pk differ diff --git a/clipboardbuffers.py b/clipboardbuffers.py new file mode 100644 index 0000000..5ba6706 --- /dev/null +++ b/clipboardbuffers.py @@ -0,0 +1,90 @@ +import sys +import os +import subprocess +import time +import pyperclip +import pyautogui as pg +from PyHotKey import Key, keyboard +import pickle +import tkinter as tk + +#pg.prompt(text="deez nuts?", title="deez nutz!", default="deez nars") + +def dumpClipboardBufferToFile(): + global clipboardBuffer + with open("clipboardBufferData.pk", 'wb') as fi: + pickle.dump(clipboardBuffer, fi) + +def getClipboardBufferFromFile(): + global clipboardBuffer + with open("clipboardBufferData.pk", 'rb') as fi: + clipboardBuffer = pickle.load(fi) + +#scriptFolder = (os.path.dirname(__file__)) +clipboardBuffer = [] +clipboardBuffer = ["No value in this clipboard buffer" for i in range(10)] + +#check if pickle file exists, if not, then create one +if os.path.isfile("clipboardBufferData.pk"): + getClipboardBufferFromFile() +else: + dumpClipboardBufferToFile() + +def inputbox(inputBuffer): + inputText = "No Input Given Yet" + window = tk.Tk() + window.title(f'Clipboard Buffer {inputBuffer}') + textbox = tk.Entry(window, width=70) + textbox.pack() + textbox.insert(0, clipboardBuffer[inputBuffer]) + textbox.focus_set() + def entry_select_all(event): + event.widget.select_range(0, 'end') + event.widget.icursor('end') + return 'break' + def entry_ctrl_backspace(event): + end_idx = textbox.index(tk.INSERT) + start_idx = textbox.get().rfind(" ", None, end_idx) + textbox.selection_range(start_idx, end_idx) + def onclick(pos): + nonlocal inputText + inputText = textbox.get() + global clipboardBuffer + clipboardBuffer[inputBuffer] = inputText + print(f"Clipboard buffer {inputBuffer} was set to: {inputText}") + window.destroy() + b = tk.Button(window, text="OK", width=10, command=onclick) + b.pack() + textbox.bind('', onclick) + textbox.bind('', onclick) + textbox.bind('', entry_ctrl_backspace) + textbox.bind('', entry_select_all) + window.mainloop() + print(clipboardBuffer) + dumpClipboardBufferToFile() + return (inputText) + + +def sendMessage(message): + subprocess.Popen(['notify-send', message]) + return + +def typeBuffer(inputBuffer): + global clipboardBuffer +# pyautogui.write(clipboardBuffer[inputBuffer]) + keyboard.type(clipboardBuffer[inputBuffer]) +def copyToBuffer(inputBuffer): + global clipboardBuffer +# clip = pyperclip.paste() + clip = os.popen('xsel -op').read() + sendMessage(f"Copied to buffer {inputBuffer}:\n===================\n{clip}") + clipboardBuffer[inputBuffer] = clip + print(clipboardBuffer[inputBuffer]) + dumpClipboardBufferToFile() + +if sys.argv[1] == "paste": + typeBuffer(int(sys.argv[2])) +if sys.argv[1] == "copy": + copyToBuffer(int(sys.argv[2])) +if sys.argv[1] == "edit": + inputbox(int(sys.argv[2])) diff --git a/gamingpc/__pycache__/windowsVidModeFunctions.cpython-312.pyc b/gamingpc/__pycache__/windowsVidModeFunctions.cpython-312.pyc new file mode 100644 index 0000000..62f76ce Binary files /dev/null and b/gamingpc/__pycache__/windowsVidModeFunctions.cpython-312.pyc differ diff --git a/gamingpc/__pycache__/windowsVidModeFunctions.cpython-313.pyc b/gamingpc/__pycache__/windowsVidModeFunctions.cpython-313.pyc new file mode 100644 index 0000000..f856170 Binary files /dev/null and b/gamingpc/__pycache__/windowsVidModeFunctions.cpython-313.pyc differ diff --git a/gamingpc/monitorLin.py b/gamingpc/monitorLin.py new file mode 100755 index 0000000..04c9e68 --- /dev/null +++ b/gamingpc/monitorLin.py @@ -0,0 +1,6 @@ +import sys +from windowsVidModeFunctions import * +monProfile("1280x960@120i") +os.system("~/sh/monitormodes/reset") +os.system("sudo /usr/bin/ddcutil setvcp --sn HTJM400760 60 6 &") +scriptRun("D:/Scripts/controlmymonitor/controlmymonitor.exe /SetValue HTJM400760 60 6") diff --git a/gamingpc/monitorWin.py b/gamingpc/monitorWin.py new file mode 100755 index 0000000..eb8353f --- /dev/null +++ b/gamingpc/monitorWin.py @@ -0,0 +1,6 @@ +import sys +from windowsVidModeFunctions import * +os.system("xrandr --output HDMI-3 --off") +monProfile("4monitors") +os.system("sudo /usr/bin/ddcutil setvcp --sn HTJM400760 60 9 &") +scriptRun("D:/Scripts/controlmymonitor/controlmymonitor.exe /SetValue HTJM400760 60 9 " ) diff --git a/gamingpc/old/__pycache__/windowsVidModeFunctions.cpython-312.pyc b/gamingpc/old/__pycache__/windowsVidModeFunctions.cpython-312.pyc new file mode 100644 index 0000000..5ef616f Binary files /dev/null and b/gamingpc/old/__pycache__/windowsVidModeFunctions.cpython-312.pyc differ diff --git a/gamingpc/old/btoff.sh b/gamingpc/old/btoff.sh new file mode 100755 index 0000000..560c7d4 --- /dev/null +++ b/gamingpc/old/btoff.sh @@ -0,0 +1,4 @@ +#!/bin/bash +bluetoothctl disconnect 9B:40:B0:7F:F9:9F +#bluetoothctl power off +notify-send "bluetooth headset disconnected" diff --git a/gamingpc/old/bton.sh b/gamingpc/old/bton.sh new file mode 100755 index 0000000..c449b7f --- /dev/null +++ b/gamingpc/old/bton.sh @@ -0,0 +1,5 @@ +#!/bin/bash +bluetoothctl power on +sleep 5 +bluetoothctl connect 9B:40:B0:7F:F9:9F +notify-send "bluetooth headset connected" diff --git a/gamingpc/old/linScreenOff b/gamingpc/old/linScreenOff new file mode 100755 index 0000000..59de581 --- /dev/null +++ b/gamingpc/old/linScreenOff @@ -0,0 +1,2 @@ +#!/bin/bash +ssh -J gpc xmonad-rad xset -display :0 dpms force off diff --git a/gamingpc/old/monitorLin.sh b/gamingpc/old/monitorLin.sh new file mode 100755 index 0000000..28bd344 --- /dev/null +++ b/gamingpc/old/monitorLin.sh @@ -0,0 +1,4 @@ +#!/bin/bash +sudo /usr/bin/ddcutil setvcp --sn HTJM400760 60 7 & +sshLucka("lucka@gaming-win 'D: && /Scripts/controlmymonitor/controlmymonitor.exe /SetValue HTJM400760 60 6'") + diff --git a/gamingpc/old/monitorWin.sh b/gamingpc/old/monitorWin.sh new file mode 100755 index 0000000..8aeb9fb --- /dev/null +++ b/gamingpc/old/monitorWin.sh @@ -0,0 +1,4 @@ +#!/bin/bash +sudo /usr/bin/ddcutil setvcp --sn HTJM400760 60 7 & +ssh vrtest@gaming-pc 'D: && /Scripts/controlmymonitor/controlmymonitor.exe /SetValue HTJM400760 60 6' + diff --git a/gamingpc/old/multiplayer.sh b/gamingpc/old/multiplayer.sh new file mode 100755 index 0000000..f3747f6 --- /dev/null +++ b/gamingpc/old/multiplayer.sh @@ -0,0 +1,3 @@ +#!/bin/bash +~/sh/gamingpc/vmswap.sh ltsc2021-nv-mp +~/sh/gamingpc/vmswap.sh tv-rad-vg-mp diff --git a/gamingpc/old/off.sh b/gamingpc/old/off.sh new file mode 100755 index 0000000..ac9fc24 --- /dev/null +++ b/gamingpc/old/off.sh @@ -0,0 +1,2 @@ +ssh 192.168.0.2 sudo /sbin/poweroff +notify-send "gaming pc turned off" diff --git a/gamingpc/old/old/gaming-high.sh b/gamingpc/old/old/gaming-high.sh new file mode 100755 index 0000000..142710b --- /dev/null +++ b/gamingpc/old/old/gaming-high.sh @@ -0,0 +1,3 @@ +notify-send "switching to gaming hi-spec vm..." +ssh 192.168.0.2 /home/lucka/sh/vm/ltsc2021-nv-high +notify-send "switched to gaming hi-spec vm" diff --git a/gamingpc/old/old/gaming.sh b/gamingpc/old/old/gaming.sh new file mode 100755 index 0000000..4344010 --- /dev/null +++ b/gamingpc/old/old/gaming.sh @@ -0,0 +1,3 @@ +notify-send "switching to gaming vm..." +ssh 192.168.0.2 /home/lucka/sh/vm/ltsc2021-nv +notify-send "switched to gaming vm" diff --git a/gamingpc/old/old/media.sh b/gamingpc/old/old/media.sh new file mode 100755 index 0000000..87b7e70 --- /dev/null +++ b/gamingpc/old/old/media.sh @@ -0,0 +1,4 @@ +#!/bin/bash +notify-send "switching to media vm..." +ssh 192.168.0.2 /home/lucka/sh/vm/tv-nv +notify-send "switched to media vm" diff --git a/gamingpc/old/old/xmonad-nv.sh b/gamingpc/old/old/xmonad-nv.sh new file mode 100755 index 0000000..f810333 --- /dev/null +++ b/gamingpc/old/old/xmonad-nv.sh @@ -0,0 +1,3 @@ +notify-send "switching to nvidia workstation vm..." +ssh 192.168.0.2 /home/lucka/sh/vm/xmonad-nv +notify-send "switched to nvidia workstation vm" diff --git a/gamingpc/old/old/xmonad-off.sh b/gamingpc/old/old/xmonad-off.sh new file mode 100755 index 0000000..0d83946 --- /dev/null +++ b/gamingpc/old/old/xmonad-off.sh @@ -0,0 +1,3 @@ +ssh 192.168.0.2 virsh -c qemu:///system shutdown xmonad-rad +notify-send "powered off workstation VM" + diff --git a/gamingpc/old/old/xmonad-on.sh b/gamingpc/old/old/xmonad-on.sh new file mode 100755 index 0000000..de8bfd9 --- /dev/null +++ b/gamingpc/old/old/xmonad-on.sh @@ -0,0 +1,3 @@ +ssh 192.168.0.2 virsh -c qemu:///system start xmonad-rad +notify-send "powered on workstation VM" + diff --git a/gamingpc/old/on.sh b/gamingpc/old/on.sh new file mode 100755 index 0000000..91a917a --- /dev/null +++ b/gamingpc/old/on.sh @@ -0,0 +1,2 @@ +wakeonlan D0:50:99:C3:29:4D +notify-send "gaming pc turned on" diff --git a/gamingpc/old/reboot.sh b/gamingpc/old/reboot.sh new file mode 100755 index 0000000..268e41c --- /dev/null +++ b/gamingpc/old/reboot.sh @@ -0,0 +1,2 @@ +ssh 192.168.0.2 sudo /sbin/reboot +notify-send "gaming pc rebooted" diff --git a/gamingpc/old/vmswap.sh b/gamingpc/old/vmswap.sh new file mode 100755 index 0000000..e2118c7 --- /dev/null +++ b/gamingpc/old/vmswap.sh @@ -0,0 +1,5 @@ +newvm=$1 +echo $newvm +notify-send "switching to $newvm vm..." +ssh gaming-pc /home/lucka/sh/vm/swap-nv $newvm +notify-send "switched to $newvm vm" diff --git a/gamingpc/old/windowsVidMode.py b/gamingpc/old/windowsVidMode.py new file mode 100644 index 0000000..2edb66d --- /dev/null +++ b/gamingpc/old/windowsVidMode.py @@ -0,0 +1,3 @@ +import sys +from windowsVidModeFunctions import * +monProfile(sys.argv[1]) diff --git a/gamingpc/old/windowsVidModeFunctions.py b/gamingpc/old/windowsVidModeFunctions.py new file mode 100644 index 0000000..abf795d --- /dev/null +++ b/gamingpc/old/windowsVidModeFunctions.py @@ -0,0 +1,39 @@ +import os +import time + +#Functions, hotkeys are at the bottom +def scriptRun(batchcode): + sshLucka(f"lucka@gaming-win 'echo {batchcode} > script.bat && schtasks /Run /TN script'") +def monProfile(profile): + scriptRun(f"D:/scripts/MonitorProfileSwitcher_v0700\MonitorSwitcher.exe -load:C:/Users/vmtest/AppData/Roaming/MonitorSwitcher/Profiles/{profile}.xml") +def sshLucka(command): + os.system(f"sudo -u lucka ssh -i /home/lucka/.ssh/id_rsa {command}") +def monitorLin(): + sshLucka("lucka@workstation-rad sudo /usr/bin/ddcutil setvcp --sn HTJM400760 60 7 &") + sshLucka("lucka@gaming-win 'D: && /Scripts/controlmymonitor/controlmymonitor.exe /SetValue HTJM400760 60 6'") +def monitorWin(): + sshLucka("lucka@workstation-rad sudo /usr/bin/ddcutil setvcp --sn HTJM400760 60 6 &") + sshLucka("lucka@gaming-win 'D: && /Scripts/controlmymonitor/controlmymonitor.exe /SetValue HTJM400760 60 5'") +def res640x480(): + scriptRun("res 640 480 120 p") +def res1280x960(): + monProfile("1280x960@120i") +def res1600x1200(): + monProfile("1600x1200@100i") +def res1600x900(): + monProfile("1600x900@120i") +def res800x600(): + monProfile("800x600@100p") +def res960x720(): + scriptRun("res 960 720 120 i") +def linScreenOff(): + sshLucka("lucka@workstation-rad DISPLAY=:0 xset dpms force off") +def res1280x720(): + scriptRun("res 1280 720 60 p") +def wegaOnly(): + monProfile("wegaOnly") + time.sleep(1) + scriptRun("res 720 540 119 i") +def svideoOnly(): + monProfile("SVIDEO") + diff --git a/gamingpc/old/xmonad-nv.sh b/gamingpc/old/xmonad-nv.sh new file mode 100755 index 0000000..f810333 --- /dev/null +++ b/gamingpc/old/xmonad-nv.sh @@ -0,0 +1,3 @@ +notify-send "switching to nvidia workstation vm..." +ssh 192.168.0.2 /home/lucka/sh/vm/xmonad-nv +notify-send "switched to nvidia workstation vm" diff --git a/gamingpc/script.bat b/gamingpc/script.bat new file mode 100644 index 0000000..69cdd6c --- /dev/null +++ b/gamingpc/script.bat @@ -0,0 +1 @@ +D:/Scripts/controlmymonitor/controlmymonitor.exe /SetValue HTJM400760 60 6 diff --git a/gamingpc/windowsVidMode.py b/gamingpc/windowsVidMode.py new file mode 100644 index 0000000..2edb66d --- /dev/null +++ b/gamingpc/windowsVidMode.py @@ -0,0 +1,3 @@ +import sys +from windowsVidModeFunctions import * +monProfile(sys.argv[1]) diff --git a/gamingpc/windowsVidModeFunctions.py b/gamingpc/windowsVidModeFunctions.py new file mode 100644 index 0000000..97f59dc --- /dev/null +++ b/gamingpc/windowsVidModeFunctions.py @@ -0,0 +1,8 @@ +import os + +def scriptRun(batchcode): + sshCommand(f"vrtest@gaming-pc 'echo {batchcode} > script.bat && schtasks /Run /TN script'") +def monProfile(profile): + scriptRun(f"D:/scripts/MonitorProfileSwitcher_v0700/MonitorSwitcher.exe -load:C:/Users/vrtest/AppData/Roaming/MonitorSwitcher/Profiles/{profile}.xml") +def sshCommand(command): + os.system(f"ssh {command}") diff --git a/hdmi-audio-selector.sh b/hdmi-audio-selector.sh new file mode 100755 index 0000000..6bef81e --- /dev/null +++ b/hdmi-audio-selector.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +CARD="alsa_card.pci-0000_04_00.1" + +# Rofi menu with extra options + fixed bindings to avoid "failed to set binding" +CHOICE=$(echo -e "HDMI 0 (CRT)\nHDMI 5 (HDTV)" | \ +rofi -dmenu \ + -p "HDMI Audio Output" \ + -mesg "Toggle between your two HDMI monitors" \ + -i \ + -no-custom \ + -theme-str 'window {width: 420px;}' \ + -theme-str 'listview {lines: 4;}' \ + -kb-row-up "Up,Control+p" \ + -kb-row-down "Down,Control+n" \ + -kb-accept-entry "Return,KP_Enter" \ + -kb-cancel "Escape,Control+g,Control+bracketleft" \ + -kb-mode-next "" \ # disable problematic defaults + -kb-mode-previous "" ) + +case "$CHOICE" in + "HDMI 0 (CRT)") + pactl set-card-profile "$CARD" output:hdmi-stereo + notify-send "Audio Switch" "Switched to HDMI 0" -i audio-card + ;; + "HDMI 5 (HDTV)") + pactl set-card-profile "$CARD" output:hdmi-stereo-extra4 + notify-send "Audio Switch" "Switched to HDMI 5" -i audio-card + ;; + *) + exit 0 + ;; +esac + +# Small delay + move all running audio streams to the new sink +sleep 0.5 +NEW_SINK=$(pactl list short sinks | grep -E 'hdmi-stereo' | awk '{print $2}' | head -1) +pactl set-default-sink $NEW_SINK +#pactl list short sink-inputs | awk '{print $1}' | xargs -r -I {} pactl move-sink-input {} "$NEW_SINK" 2>/dev/null + diff --git a/input.sh b/input.sh new file mode 100755 index 0000000..84f7bf0 --- /dev/null +++ b/input.sh @@ -0,0 +1,17 @@ +#!/bin/bash +while : +do +read -n 2 -s -r -p "Press any key to continue: " action +echo $action +case $action in + 00) + echo "mario is real" + ;; + 01) + echo "L is real 2401" + ;; + 02) + neofetch + ;; +esac +done diff --git a/keymaps.sh b/keymaps.sh new file mode 100755 index 0000000..d8d3f4b --- /dev/null +++ b/keymaps.sh @@ -0,0 +1,9 @@ +#!/bin/bash +#======================================================= +notify-send "keymaps loaded!" +#xmodmap -e "keycode 79 = KP_7" -e "keycode 80 = KP_8" -e "keycode 81 = KP_9" -e "keycode 83 = KP_4" -e "keycode 84 = KP_5" -e "keycode 85 = KP_6" -e "keycode 87 = KP_1" -e "keycode 88 = KP_2" -e "keycode 89 = KP_3" -e "keycode 90 = KP_0" -e "keycode 91 = KP_Decimal" -e "keycode 104 = KP_Enter" +xmodmap -e 'keycode 108 = Hyper_L' +xmodmap -e 'remove mod4 = Hyper_L' +xmodmap -e 'remove mod1 = Hyper_L' +xmodmap -e 'clear mod3' +xmodmap -e 'add mod3 = Hyper_L' diff --git a/keymaps.sh.old b/keymaps.sh.old new file mode 100755 index 0000000..03604ee --- /dev/null +++ b/keymaps.sh.old @@ -0,0 +1,16 @@ +#!/bin/bash +#======================================================= +#Leave mod4 as windows key _only_ +xmodmap -e 'remove mod4 = Hyper_L' +#======================================================= +#Set mod3 to capslock +xmodmap -e 'add mod3 = Hyper_L' +#======================================================= +#bind the ><\ key next to left shift and ctrl to be the left windows key since this ibm keyboard doesnt have one +xmodmap -e 'keycode 94 = Super_L' +#======================================================= +#bind the capslock key to Hyper, which is an unused extra modifier key +#xmodmap -e 'keycode 66 = Hyper_L' +#======================================================= +#Bind hyper, when pressed and released by itself, to hit escape, because vim is cool +#pkill xcape && xcape -e 'Hyper_L=Escape' -d diff --git a/keymaps/autokey/.New Script.json b/keymaps/autokey/.New Script.json new file mode 100644 index 0000000..8a13226 --- /dev/null +++ b/keymaps/autokey/.New Script.json @@ -0,0 +1,26 @@ +{ + "type": "script", + "description": "New Script", + "store": {}, + "modes": [], + "usageCount": 0, + "prompt": false, + "omitTrigger": false, + "showInTrayMenu": false, + "abbreviation": { + "abbreviations": [], + "backspace": true, + "ignoreCase": false, + "immediate": false, + "triggerInside": false, + "wordChars": "[\\w]" + }, + "hotkey": { + "modifiers": [], + "hotKey": null + }, + "filter": { + "regex": null, + "isRecursive": false + } +} \ No newline at end of file diff --git a/keymaps/autokey/.folder.json b/keymaps/autokey/.folder.json new file mode 100644 index 0000000..c630cdc --- /dev/null +++ b/keymaps/autokey/.folder.json @@ -0,0 +1,23 @@ +{ + "type": "folder", + "title": "autokey", + "modes": [], + "usageCount": 0, + "showInTrayMenu": false, + "abbreviation": { + "abbreviations": [], + "backspace": true, + "ignoreCase": false, + "immediate": false, + "triggerInside": false, + "wordChars": "[\\w]" + }, + "hotkey": { + "modifiers": [], + "hotKey": null + }, + "filter": { + "regex": null, + "isRecursive": false + } +} \ No newline at end of file diff --git a/keymaps/autokey/New Script.py b/keymaps/autokey/New Script.py new file mode 100644 index 0000000..fb7c278 --- /dev/null +++ b/keymaps/autokey/New Script.py @@ -0,0 +1 @@ +# Enter script code \ No newline at end of file diff --git a/keymaps/autokey/copy-paste/.folder.json b/keymaps/autokey/copy-paste/.folder.json new file mode 100644 index 0000000..4ba6b51 --- /dev/null +++ b/keymaps/autokey/copy-paste/.folder.json @@ -0,0 +1,23 @@ +{ + "type": "folder", + "title": "copy-paste", + "modes": [], + "usageCount": 0, + "showInTrayMenu": false, + "abbreviation": { + "abbreviations": [], + "backspace": true, + "ignoreCase": false, + "immediate": false, + "triggerInside": false, + "wordChars": "[\\w]" + }, + "hotkey": { + "modifiers": [], + "hotKey": null + }, + "filter": { + "regex": null, + "isRecursive": false + } +} \ No newline at end of file diff --git a/keymaps/autokey/copy-paste/.type clipboard.json b/keymaps/autokey/copy-paste/.type clipboard.json new file mode 100644 index 0000000..7c4fdfd --- /dev/null +++ b/keymaps/autokey/copy-paste/.type clipboard.json @@ -0,0 +1,28 @@ +{ + "type": "script", + "description": "type clipboard", + "store": {}, + "modes": [ + 3 + ], + "usageCount": 54, + "prompt": false, + "omitTrigger": false, + "showInTrayMenu": false, + "abbreviation": { + "abbreviations": [], + "backspace": true, + "ignoreCase": false, + "immediate": false, + "triggerInside": false, + "wordChars": "[\\w]" + }, + "hotkey": { + "modifiers": [], + "hotKey": "" + }, + "filter": { + "regex": null, + "isRecursive": false + } +} \ No newline at end of file diff --git a/keymaps/autokey/copy-paste/type clipboard.py b/keymaps/autokey/copy-paste/type clipboard.py new file mode 100644 index 0000000..b80b7e9 --- /dev/null +++ b/keymaps/autokey/copy-paste/type clipboard.py @@ -0,0 +1,3 @@ +# Enter script code +content = clipboard.get_clipboard() +keyboard.send_keys(content) \ No newline at end of file diff --git a/keymaps/autokey/hotstrings/.folder.json b/keymaps/autokey/hotstrings/.folder.json new file mode 100644 index 0000000..5396c5b --- /dev/null +++ b/keymaps/autokey/hotstrings/.folder.json @@ -0,0 +1,23 @@ +{ + "type": "folder", + "title": "hotstrings", + "modes": [], + "usageCount": 0, + "showInTrayMenu": false, + "abbreviation": { + "abbreviations": [], + "backspace": true, + "ignoreCase": false, + "immediate": false, + "triggerInside": false, + "wordChars": "[\\w]" + }, + "hotkey": { + "modifiers": [], + "hotKey": null + }, + "filter": { + "regex": null, + "isRecursive": false + } +} \ No newline at end of file diff --git a/keymaps/autokey/hotstrings/.iirc.json b/keymaps/autokey/hotstrings/.iirc.json new file mode 100644 index 0000000..e8adf3f --- /dev/null +++ b/keymaps/autokey/hotstrings/.iirc.json @@ -0,0 +1,31 @@ +{ + "type": "phrase", + "description": "iirc", + "modes": [ + 1 + ], + "usageCount": 6, + "prompt": false, + "omitTrigger": false, + "matchCase": false, + "showInTrayMenu": false, + "abbreviation": { + "abbreviations": [ + "iirc" + ], + "backspace": true, + "ignoreCase": false, + "immediate": false, + "triggerInside": false, + "wordChars": "[^ \\n]" + }, + "hotkey": { + "modifiers": [], + "hotKey": null + }, + "filter": { + "regex": null, + "isRecursive": false + }, + "sendMode": "kb" +} \ No newline at end of file diff --git a/keymaps/autokey/hotstrings/.luccapirovanogmx.com.json b/keymaps/autokey/hotstrings/.luccapirovanogmx.com.json new file mode 100644 index 0000000..a4f1e8f --- /dev/null +++ b/keymaps/autokey/hotstrings/.luccapirovanogmx.com.json @@ -0,0 +1,31 @@ +{ + "type": "phrase", + "description": "luccapirovano@gmx.com", + "modes": [ + 1 + ], + "usageCount": 1, + "prompt": false, + "omitTrigger": false, + "matchCase": false, + "showInTrayMenu": false, + "abbreviation": { + "abbreviations": [ + "myemail" + ], + "backspace": true, + "ignoreCase": false, + "immediate": false, + "triggerInside": false, + "wordChars": "[^ \\n]" + }, + "hotkey": { + "modifiers": [], + "hotKey": null + }, + "filter": { + "regex": null, + "isRecursive": false + }, + "sendMode": "kb" +} \ No newline at end of file diff --git a/keymaps/autokey/hotstrings/iirc.txt b/keymaps/autokey/hotstrings/iirc.txt new file mode 100644 index 0000000..cf4c357 --- /dev/null +++ b/keymaps/autokey/hotstrings/iirc.txt @@ -0,0 +1 @@ +if I recall correctly \ No newline at end of file diff --git a/keymaps/autokey/hotstrings/luccapirovanogmx.com.txt b/keymaps/autokey/hotstrings/luccapirovanogmx.com.txt new file mode 100644 index 0000000..3769f75 --- /dev/null +++ b/keymaps/autokey/hotstrings/luccapirovanogmx.com.txt @@ -0,0 +1 @@ +luccapirovano@gmx.com \ No newline at end of file diff --git a/keymaps/map2-test.py b/keymaps/map2-test.py new file mode 100644 index 0000000..6d0c28d --- /dev/null +++ b/keymaps/map2-test.py @@ -0,0 +1,22 @@ +import time +import map2 + +# readers intercept all keyboard inputs and forward them +reader = map2.Reader(patterns=["/dev/input/by-id/usb-Lite-On_Tech_IBM_USB_Travel_Keyboard_with_Ultra_Nav-event-kbd"]) + +# mappers change inputs, you can also chain multiple mappers! +mapper = map2.Mapper() + +# writers create new virtual devices we can write into +writer = map2.Writer(clone_from = "/dev/input/by-id/usb-Lite-On_Tech_IBM_USB_Travel_Keyboard_with_Ultra_Nav-event-kbd") + +# finally, link nodes to control the event flow +map2.link([reader, mapper, writer]) + +mapper.map("!j", "{ctrl down}{pagedown}{ctrl up}") +mapper.map("!+j", "{ctrl down}{shift down}{pagedown}{shift up}{ctrl up}") +mapper.map("!k", "{ctrl down}{pageup}{ctrl up}") +mapper.map("!+k", "{ctrl down}{shift down}{pageup}{shift up}{ctrl up}") + +# keep running indefinitely +map2.wait() diff --git a/keymaps/test.ahk b/keymaps/test.ahk new file mode 100644 index 0000000..e69de29 diff --git a/keymapsUdev.sh b/keymapsUdev.sh new file mode 100755 index 0000000..240dd95 --- /dev/null +++ b/keymapsUdev.sh @@ -0,0 +1,3 @@ +#!/bin/bash +#======================================================= +exec nohup /home/lucka/sh/keymaps.sh & diff --git a/lgctl b/lgctl new file mode 120000 index 0000000..6b86b31 --- /dev/null +++ b/lgctl @@ -0,0 +1 @@ +lgctl.sh \ No newline at end of file diff --git a/lgctl.sh b/lgctl.sh new file mode 100755 index 0000000..85e8256 --- /dev/null +++ b/lgctl.sh @@ -0,0 +1,2 @@ +#!/bin/bash +ssh gaming-win 'sc '$1' "Looking Glass (host)"' diff --git a/monitormodes.sh b/monitormodes.sh new file mode 100755 index 0000000..3dea335 --- /dev/null +++ b/monitormodes.sh @@ -0,0 +1,4 @@ +#!/bin/bash +scriptfolder=~/sh/monitormodes +cd $scriptfolder +bash ./$(ls . | rofi -dmenu -drun -p "Run: ") diff --git a/mount-all-filesystems.sh b/mount-all-filesystems.sh new file mode 100755 index 0000000..6951a3a --- /dev/null +++ b/mount-all-filesystems.sh @@ -0,0 +1,4 @@ +#!/bin/bash +sshfs nas.mario:/mnt/b8ce9a57-7ce7-47b8-a233-21184c8a0953/share ~/share -o reconnect -o ServerAliveInterval=15 +sshfs gaming-win:/ ~/mnt/gaming-win +sshfs nas.mario:/mnt/mario/ ~/mnt/mario diff --git a/move-to-next-monitor b/move-to-next-monitor new file mode 100755 index 0000000..b4ea351 --- /dev/null +++ b/move-to-next-monitor @@ -0,0 +1,75 @@ +#!/bin/bash +# +# Move the current window to the next monitor. +# +# Also works only on one X screen (which is the most common case). +# +# Props to +# http://icyrock.com/blog/2012/05/xubuntu-moving-windows-between-monitors/ +# +# Unfortunately, both "xdotool getwindowgeometry --shell $window_id" and +# checking "-geometry" of "xwininfo -id $window_id" are not sufficient, as +# the first command does not respect panel/decoration offsets and the second +# will sometimes give a "-0-0" geometry. This is why we resort to "xwininfo". + +screen_width=$(xdpyinfo | awk '/dimensions:/ { print $2; exit }' | cut -d"x" -f1) +screen_height=$(xdpyinfo | awk '/dimensions:/ { print $2; exit }' | cut -d"x" -f2) +display_width=$(xdotool getdisplaygeometry | cut -d" " -f1) +display_height=$(xdotool getdisplaygeometry | cut -d" " -f2) +window_id=$(xdotool getactivewindow) + +# Remember if it was maximized. +window_horz_maxed=$(xprop -id "$window_id" _NET_WM_STATE | grep '_NET_WM_STATE_MAXIMIZED_HORZ') +window_vert_maxed=$(xprop -id "$window_id" _NET_WM_STATE | grep '_NET_WM_STATE_MAXIMIZED_VERT') + +# Un-maximize current window so that we can move it +wmctrl -ir "$window_id" -b remove,maximized_vert,maximized_horz + +# Read window position +x=$(xwininfo -id "$window_id" | awk '/Absolute upper-left X:/ { print $4 }') +y=$(xwininfo -id "$window_id" | awk '/Absolute upper-left Y:/ { print $4 }') + +# Subtract any offsets caused by panels or window decorations +x_offset=$(xwininfo -id "$window_id" | awk '/Relative upper-left X:/ { print $4 }') +y_offset=$(xwininfo -id "$window_id" | awk '/Relative upper-left Y:/ { print $4 }') +x=$(( x - x_offset)) +y=$(( y - y_offset)) + +# Compute new X position +new_x=$((x + display_width)) +# Compute new Y position +new_y=$((y + display_height)) + +# If we would move off the right-most monitor, we set it to the left one. +# We also respect the window's width here: moving a window off more than half its width won't happen. +width=$(xdotool getwindowgeometry "$window_id" | awk '/Geometry:/ { print $2 }'|cut -d"x" -f1) +if [ "$(( new_x + width / 2))" -gt "$screen_width" ]; then + new_x=$((new_x - screen_width)) +fi + +height=$(xdotool getwindowgeometry "$window_id" | awk '/Geometry:/ { print $2 }'|cut -d"x" -f2) +if [ "$((new_y + height / 2))" -gt "$screen_height" ]; then + new_y=$((new_y - screen_height)) +fi + +# Don't move off the left side. +if [ "$new_x" -lt 0 ]; then + new_x=0 +fi + +# Don't move off the bottom +if [ "$new_y" -lt 0 ]; then + new_y=0 +fi + +# Move the window +xdotool windowmove "$window_id" "$new_x" "$new_y" + +# Maximize window again, if it was before +if [ -n "${window_horz_maxed}" ] && [ -n "${window_vert_maxed}" ]; then + wmctrl -ir "$window_id" -b add,maximized_vert,maximized_horz +elif [ -n "${window_horz_maxed}" ]; then + wmctrl -ir "$window_id" -b add,maximized_horz +elif [ -n "${window_vert_maxed}" ]; then + wmctrl -ir "$window_id" -b add,maximized_vert +fi diff --git a/mpv-openclipboard.sh b/mpv-openclipboard.sh new file mode 100755 index 0000000..26fcec7 --- /dev/null +++ b/mpv-openclipboard.sh @@ -0,0 +1,2 @@ +#!/bin/bash +mpv $(xclip -sel clip -o) diff --git a/nohup.out b/nohup.out new file mode 100644 index 0000000..e69de29 diff --git a/notification-parse.sh b/notification-parse.sh new file mode 100755 index 0000000..fc14e6d --- /dev/null +++ b/notification-parse.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +n1='cute ass mf' +n2='backthr0w' +n3='lucca' + +dbus-monitor "interface=org.freedesktop.Notifications" | grep -B 50 -i "dev.vencord.Vesktop" | grep -i -e "$n1" -e "$n2" -e $n3 --line-buffered | +while read found_line; do + echo "$found_line" + mpv --volume=50 --force-window=no "${HOME}/share/audio/dark_souls_2_parry.mp3" # replace with your command & +# ssh gaming-pc.mario F:/Scripts/jabra-headset-keepawake/mpv.exe F:/scripts/jabra-headset-keepawake/dark_souls_2_parry.mp3 +done diff --git a/numpad-hotkeys-keyd.sh b/numpad-hotkeys-keyd.sh new file mode 100755 index 0000000..f7f6efb --- /dev/null +++ b/numpad-hotkeys-keyd.sh @@ -0,0 +1,46 @@ +#!/bin/bash +sudo keyd monitor | +while + read; + do + if echo "$REPLY" | fgrep "04d9:1503:20f521c9"; then + if echo "$REPLY" | fgrep "kp0 down"; then echo "this is button 0"; + fi + if echo "$REPLY" | fgrep "kp1 down"; then echo "this is button 1"; + fi + if echo "$REPLY" | fgrep "kp2 down"; then echo "this is button 2"; + fi + if echo "$REPLY" | fgrep "kp3 down"; then echo "this is button 3"; + fi + if echo "$REPLY" | fgrep "kp4 down"; then echo "this is button 4"; + fi + if echo "$REPLY" | fgrep "kp5 down"; then echo "this is button 5"; + fi + if echo "$REPLY" | fgrep "kp6 down"; then echo "this is button 6"; + ~/sh/rmctrl/commands/wega toggle + fi + if echo "$REPLY" | fgrep "kp7 down"; then echo "this is button 7"; + python3 ~/sh/gamingpc/monitorLin.py + fi + if echo "$REPLY" | fgrep "kp8 down"; then echo "this is button 8"; + python3 ~/sh/gamingpc/monitorWin.py + fi + if echo "$REPLY" | fgrep "kp9 down"; then echo "this is button 9"; + fi + if echo "$REPLY" | fgrep "numlock down"; then echo "this is button numlock"; + ~/sh/rmctrl/commands/lightoff + fi + if echo "$REPLY" | fgrep "kpslash down"; then echo "this is button /"; + ~/sh/rmctrl/commands/lighton + fi + if echo "$REPLY" | fgrep "kpasterisk down"; then echo "this is button *"; + ~/sh/rmctrl/commands/monitoroff + fi + if echo "$REPLY" | fgrep "backspace down"; then echo "this is button backspace"; + ~/sh/rmctrl/commands/monitoron + fi + if echo "$REPLY" | fgrep "kpenter down"; then echo "this is button kpenter"; + curl -v -u lucka:h0gC3PMwSCXjJH8L 'http://wattbox.mario/control.cgi?outlet=2&command=0' & + fi + fi + done diff --git a/ps3-controller-bluetooth-latency-fix.sh b/ps3-controller-bluetooth-latency-fix.sh new file mode 100755 index 0000000..5af1dd1 --- /dev/null +++ b/ps3-controller-bluetooth-latency-fix.sh @@ -0,0 +1,95 @@ +#!/usr/bin/env bash + +# setup-ps3-bt-slave-poller.sh +# ============================ +# Installs a systemd service + script to poll for your PS3 controllers +# and force slave/peripheral mode (PC master) when connected. +# No udev timing issues. Works around hcitool sr race. + +set -euo pipefail + +MACS=("00:1B:FB:F0:7C:85" "00:1B:FB:F3:D2:25" "00:1B:FB:6A:1E:E4") + +SERVICE_FILE="/etc/systemd/system/ps3-bt-slave.service" +POLLER_SCRIPT="/usr/local/bin/ps3-bt-slave-poller.sh" +HCITOOL="$(which hcitool 2>/dev/null || echo "/usr/bin/hcitool")" + +if [[ ${EUID:-} -ne 0 ]]; then + echo "Run with sudo." + exit 1 +fi + +if [[ ! -x "$HCITOOL" ]]; then + echo "hcitool missing. Install bluez-deprecated-tools:" + echo " sudo apt install bluez-deprecated-tools (Debian/Ubuntu/Mint)" + echo " or equivalent for your distro." + exit 1 +fi + +echo "Creating poller script: $POLLER_SCRIPT" + +cat > "$POLLER_SCRIPT" << 'EOP' +#!/usr/bin/env bash +# ps3-bt-slave-poller.sh - background checker for PS3 BT role switch + +MACS=("00:1B:FB:F0:7C:85" "00:1B:FB:F3:D2:25" "00:1B:FB:6A:1E:E4") +LOG="/tmp/ps3-bt-slave-poller.log" + +while true; do + for mac in "${MACS[@]}"; do + if hcitool con | grep -q "$mac"; then + # Connected → force slave/peripheral + echo "$(date '+%Y-%m-%d %H:%M:%S') - $mac connected, forcing slave" >> "$LOG" + hcitool sr "$mac" slave >> "$LOG" 2>&1 || echo "$(date '+%Y-%m-%d %H:%M:%S') - Failed for $mac" >> "$LOG" + fi + done + sleep 10 +done +EOP + +chmod +x "$POLLER_SCRIPT" +echo "Poller script created." + +echo "Creating systemd service: $SERVICE_FILE" + +cat > "$SERVICE_FILE" << EOF +[Unit] +Description=PS3 Bluetooth Slave/Peripheral Mode Poller +After=bluetooth.service network.target + +[Service] +ExecStart=$POLLER_SCRIPT +Restart=always +RestartSec=5 +User=root + +[Install] +WantedBy=multi-user.target +EOF + +echo "Service file created." + +echo "Enabling/starting service..." +systemctl daemon-reload +systemctl enable --now ps3-bt-slave.service + +echo "" +echo "=== Setup Complete ===" +echo "The poller runs in background. After any controller connects:" +echo " - Wait 10-30 seconds" +echo " - Run: hcitool con" +echo " → Should show lm PERIPHERAL (good) instead of lm CENTRAL" +echo "" +echo "Check log for activity/errors:" +echo " tail -f /tmp/ps3-bt-slave-poller.log" +echo "" +echo "Test:" +echo " 1. Disconnect controller fully (hold PS ~10s, lights off)" +echo " 2. Reconnect (press PS button)" +echo " 3. Wait 20-30s" +echo " 4. hcitool con" +echo "" +echo "If still CENTRAL after 30s: Check log for 'Failed' → may need different adapter or accept manual 'sudo hcitool sr MAC slave' after connect." +echo "To stop/uninstall: sudo systemctl stop ps3-bt-slave.service && sudo systemctl disable ps3-bt-slave.service" + +exit 0 diff --git a/quest-cast.sh b/quest-cast.sh new file mode 100755 index 0000000..9c6f1ab --- /dev/null +++ b/quest-cast.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +adb tcpip 5555 +sleep 1 +adb connect 10.0.0.30:5555 +read -p "Disconnect from USB and press Enter to continue" + +set -e +trap 'kill 0' EXIT + +screen_record() { + adb exec-out screenrecord \ + --bit-rate=5m \ + --output-format=h264 \ + --size 1832x960 \ + --time-limit=0 \ + - +} + +stream_play() { + ffplay \ + -framerate 30 \ + -fflags nobuffer+discardcorrupt\ + -flags low_delay \ + -framedrop \ + -strict experimental \ + -analyzeduration 100000 \ + -probesize 32 \ + -sync ext \ + -vf "setpts=PTS-STARTPTS,crop=916:960:0:0" \ + - +} + +# uncomment for audio + scrcpy --no-video --audio-buffer=200 & + +screen_record | stream_play diff --git a/quest-cast2.sh b/quest-cast2.sh new file mode 100755 index 0000000..04906af --- /dev/null +++ b/quest-cast2.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +# Enable ADB over TCP (run once usually) +adb tcpip 5555 +sleep 1 +adb connect 10.0.0.30:5555 || { echo "Connection failed - check IP/Wi-Fi"; exit 1; } + +read -p "Disconnect USB now if desired, then press Enter..." + +set -e +trap 'kill 0' EXIT INT TERM + +stream_play() { + ffplay \ + -fflags nobuffer+discardcorrupt+flush_packets \ + -flags low_delay \ + -framedrop \ + -probesize 32 \ + -analyzeduration 0 \ + -sync ext \ + -vf "setpts=PTS-STARTPTS" \ + - +} + +# Optional audio (low buffer, background) +# scrcpy --no-video --audio-buffer=80 --audio-bit-rate=128K & + +echo "Starting low-latency Quest mirror (Wi-Fi). Ctrl+C to stop." +echo "Expect 150–500 ms latency depending on network." + +while true; do + echo "[$(date '+%H:%M:%S')] (Re)starting screenrecord segment..." + + adb exec-out screenrecord \ + --bit-rate=8M \ + --output-format=h264 \ + --size 1280x720 \ + --time-limit 120 \ + - | stream_play + + # Small delay to let ffplay drain & avoid rapid respawn spam on error + sleep 0.5 +done diff --git a/quest-cast3.sh b/quest-cast3.sh new file mode 100755 index 0000000..bccf054 --- /dev/null +++ b/quest-cast3.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +# Quest 2 wireless mirror to PC → 480i CRT (ultra-low quality for min game lag/latency) +# Removed --stay-awake (conflicts with --no-control) + fixed previous issues + +IP="10.0.0.30:5555" + +echo "Enabling ADB over TCP..." +adb tcpip 5555 +sleep 2 + +echo "Connecting to Quest..." +adb connect "${IP}" + +echo "" +echo "ADB devices (should list your Quest):" +adb devices + +echo "" +read -p "Disconnect USB now. Wake Quest fully (put it on), launch game/app, press Enter..." + +echo "" +echo "Starting scrcpy... (fullscreen the window with F11 or OS shortcut; q/Ctrl+C to quit)" +echo "" + +scrcpy -s "${IP}" \ +# --crop=1832:960:1832:0 \ + --crop=1832:960:0:0 \ + --max-size=640 \ + --max-fps=30 \ + --video-bit-rate=800K \ + --no-audio \ + --no-control \ + --always-on-top \ + --window-width=640 \ + --window-height=480 \ + --window-borderless + +echo "" +echo "Troubleshooting:" +echo " - Black screen? Try left-eye crop instead: change to --crop=1832:960:0:0" +echo " Or tweak offset: --crop=1832:960:1700:100 (experiment in 100-pixel steps)" +echo " - Still black/no video? Add this to the scrcpy line:" +echo " --encoder=OMX.google.h264.encoder" +echo " (forces a software encoder on Quest — often fixes black screens on Horizon OS)" +echo " - Game lag/stutter? Lower further: --video-bit-rate=500K or --max-size=480" +echo " - Output HDMI from PC → cheap HDMI-to-composite adapter → your 480i CRT" +echo " - Quest sleeps too fast? Enable 'Stay awake' manually in Quest Developer Options (while charging via USB briefly)" diff --git a/quest-cast4.sh b/quest-cast4.sh new file mode 100755 index 0000000..5f7d094 --- /dev/null +++ b/quest-cast4.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Quest 2 wireless mirror to PC → 480i CRT (ultra-low quality for min game lag/latency) +# Removed --stay-awake (conflicts with --no-control) + fixed previous issues + +IP="10.0.0.30:5555" + +echo "Enabling ADB over TCP..." +adb tcpip 5555 +sleep 2 + +echo "Connecting to Quest..." +adb connect "${IP}" + +echo "" +echo "ADB devices (should list your Quest):" +adb devices + +echo "" +read -p "Disconnect USB now. Wake Quest fully (put it on), launch game/app, press Enter..." + +echo "" +echo "Starting scrcpy... (fullscreen the window with F11 or OS shortcut; q/Ctrl+C to quit)" +echo "" + +scrcpy -s "${IP}" \ +# --crop=1832:960:1832:0 \ + --crop=1832:960:0:0 \ + --max-size=640 \ + --max-fps=30 \ + --video-bit-rate=800K \ + --no-control \ + --always-on-top \ + --window-width=640 \ + --window-height=480 \ + --window-borderless + +echo "" +echo "Troubleshooting:" +echo " - Black screen? Try left-eye crop instead: change to --crop=1832:960:0:0" +echo " Or tweak offset: --crop=1832:960:1700:100 (experiment in 100-pixel steps)" +echo " - Still black/no video? Add this to the scrcpy line:" +echo " --encoder=OMX.google.h264.encoder" +echo " (forces a software encoder on Quest — often fixes black screens on Horizon OS)" +echo " - Game lag/stutter? Lower further: --video-bit-rate=500K or --max-size=480" +echo " - Output HDMI from PC → cheap HDMI-to-composite adapter → your 480i CRT" +echo " - Quest sleeps too fast? Enable 'Stay awake' manually in Quest Developer Options (while charging via USB briefly)" diff --git a/quest-cast5.sh b/quest-cast5.sh new file mode 100755 index 0000000..c0f3ece --- /dev/null +++ b/quest-cast5.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# Quest 2 wireless mirror to PC → 480i CRT +# --no-audio ensures Quest headset NOT muted (sound stays in-headset) +# Left-eye crop (since right gave black; tweak if needed) + +IP="10.0.0.30:5555" + +echo "Enabling ADB over TCP..." +adb tcpip 5555 +sleep 2 + +echo "Connecting to Quest..." +adb connect "${IP}" + +echo "" +echo "ADB devices (should list your Quest):" +adb devices + +echo "" +read -p "Disconnect USB now. Wake Quest fully (put it on), launch game/app, press Enter..." + +echo "" +echo "Starting scrcpy... (fullscreen with F11 or similar; q/Ctrl+C to quit)" +echo "" + +scrcpy -s "${IP}" \ + --crop=1832:960:0:0 \ + --max-size=640 \ + --max-fps=30 \ + --video-bit-rate=800K \ + --no-audio \ + --no-control \ + --always-on-top \ + --window-width=640 \ + --window-height=480 \ + --window-borderless + +echo "" +echo "Troubleshooting:" +echo " - Black screen? Try centered/right-ish crop: --crop=1600:900:2017:510" +echo " Or simple right half: --crop=1832:960:1832:0" +echo " Add --encoder=OMX.google.h264.encoder if black persists (forces software encoder)" +echo " - Audio still muted on Quest? Double-check no other flags removed --no-audio; restart Quest if stuck" +echo " - Game lag? Lower to --video-bit-rate=500K or --max-size=480" +echo " - HDMI from PC → composite adapter → CRT" diff --git a/quest-cast6.sh b/quest-cast6.sh new file mode 100755 index 0000000..31a983f --- /dev/null +++ b/quest-cast6.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +# Quest 2 wireless mirror to PC → 480i CRT +# Updated crop to avoid lens top (centered single view) + audio on Quest + +IP="10.0.0.30:5555" + +echo "Enabling ADB over TCP..." +adb tcpip 5555 +sleep 2 + +echo "Connecting to Quest..." +adb connect "${IP}" + +echo "" +echo "ADB devices (should list your Quest):" +adb devices + +echo "" +read -p "Disconnect USB now. Wake Quest fully (put it on), launch game/app, press Enter..." + +echo "" +echo "Starting scrcpy... (fullscreen with F11 or similar; q/Ctrl+C to quit)" +echo "" + +scrcpy -s "${IP}" \ + --crop=1600:900:2017:510 \ + --max-size=640 \ + --max-fps=30 \ + --video-bit-rate=800K \ + --no-audio \ + --no-control \ + --always-on-top \ + --window-width=640 \ + --window-height=480 \ + --window-borderless + +echo "" +echo "Troubleshooting:" +echo " - Still seeing lens top/empty area? Try higher y-offset: --crop=1600:900:2017:550" +echo " Or alternative crops:" +echo " --crop=1600:900:68:495 (left-leaning centered view)" +echo " --crop=1832:960:1832:100 (simple right half, shifted down a bit)" +echo " - Black screen? Add --encoder=OMX.google.h264.encoder" +echo " - Crop feels off-center/UI cut? Tweak x-offset by 50–100 (e.g. 2017 → 1950 or 2100)" +echo " - Game lag? Lower --video-bit-rate=500K or --max-size=480" +echo " - HDMI from PC → composite adapter → CRT" diff --git a/quest-cast7.sh b/quest-cast7.sh new file mode 100755 index 0000000..34f2c86 --- /dev/null +++ b/quest-cast7.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Quest 2 wireless mirror to PC → 480i CRT +# Only crop changed for better 4:3 compatibility (taller source to reduce bars) + +IP="10.0.0.30:5555" + +echo "Enabling ADB over TCP..." +adb tcpip 5555 +sleep 2 + +echo "Connecting to Quest..." +adb connect "${IP}" + +echo "" +echo "ADB devices (should list your Quest):" +adb devices + +echo "" +read -p "Disconnect USB now. Wake Quest fully (put it on), launch game/app, press Enter..." + +echo "" +echo "Starting scrcpy... (fullscreen with F11 or similar; q/Ctrl+C to quit)" +echo "" + +scrcpy -s "${IP}" \ + --crop=1440:1080:2017:420 \ + --max-size=800 \ + --max-fps=30 \ + --video-bit-rate=800K \ + --no-audio \ + --no-control \ + --always-on-top \ + --window-width=640 \ + --window-height=480 \ + --window-borderless + +echo "" +echo "Troubleshooting:" +echo " - Too much lens top again? Increase y-offset: --crop=1440:1080:2017:480" +echo " - Cuts bottom/UI? Lower y-offset back: --crop=1440:1080:2017:510 or try original 1600:900:2017:510" +echo " - Still too many black bars? Use wider source: --crop=1500:1125:2017:450 (closer to 4:3 fill)" +echo " - Black screen? Add --encoder=OMX.google.h264.encoder" +echo " - HDMI from PC → composite adapter → CRT" diff --git a/quest-cast8.sh b/quest-cast8.sh new file mode 100755 index 0000000..0176eff --- /dev/null +++ b/quest-cast8.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# Quest 2 wireless mirror to PC → 480i CRT +# No crop to reduce flickering/black intermittents (common fix for Horizon OS 74+) + +IP="10.0.0.30:5555" + +echo "Enabling ADB over TCP..." +adb tcpip 5555 +sleep 2 + +echo "Connecting to Quest..." +adb connect "${IP}" + +echo "" +echo "ADB devices (should list your Quest):" +adb devices + +echo "" +read -p "Disconnect USB now. Put on Quest fully, launch game/app FIRST, then press Enter..." + +echo "" +echo "Starting scrcpy... (fullscreen with F11; q/Ctrl+C to quit)" +echo "" + +scrcpy -s "${IP}" \ + --max-size=480 \ + --max-fps=15 \ + --video-bit-rate=400K \ + --no-audio \ + --no-control \ + --always-on-top \ + --window-width=640 \ + --window-height=480 \ + --window-borderless + +echo "" +echo "Troubleshooting:" +echo " - Flicker gone? Re-add crop later (--crop=1440:1080:2017:420) and test if it returns" +echo " - Still flickers? Try --encoder=OMX.google.h264.encoder or lower bitrate to 500K" +echo " - Wider black bars now? Normal without crop — use OBS crop if needed" +echo " - HDMI PC → composite adapter → CRT" diff --git a/quest-cast9.sh b/quest-cast9.sh new file mode 100755 index 0000000..4d5528e --- /dev/null +++ b/quest-cast9.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Quest 2 wireless mirror to PC → 480i CRT +# Forced encoder + low settings to stop ~20s black flicker (Horizon OS v74+ bug) + +IP="10.0.0.30:5555" + +echo "Enabling ADB over TCP..." +adb tcpip 5555 +sleep 2 + +echo "Connecting to Quest..." +adb connect "${IP}" + +echo "" +echo "ADB devices:" +adb devices + +echo "" +read -p "Disconnect USB now. Reboot Quest if possible. Put on headset, enter game/app NOW, then press Enter..." + +echo "" +echo "Starting scrcpy (test for flicker after 20–60s)..." +echo "" + +scrcpy -s "${IP}" \ + --max-size=640 \ + --max-fps=30 \ + --video-bit-rate=800K \ + --video-encoder=c2.qti.avc.encoder \ + --no-audio \ + --no-control \ + --always-on-top \ + --window-width=640 \ + --window-height=480 \ + --window-borderless + +echo "" +echo "Next steps if flicker remains:" +echo " - Swap encoder: --video-encoder=OMX.qcom.video.encoder.avc" +echo " - Lower more: --max-size=480 --video-bit-rate=400K --max-fps=24" +echo " - Check issue #5913 on GitHub for patched binaries (search 'Quest 2 fix')" +echo " - HDMI PC out → composite adapter → CRT" diff --git a/rmctrl/.light.swp b/rmctrl/.light.swp new file mode 100644 index 0000000..2bbb6f0 Binary files /dev/null and b/rmctrl/.light.swp differ diff --git a/rmctrl/commands/lightoff b/rmctrl/commands/lightoff new file mode 100755 index 0000000..5a3acc8 --- /dev/null +++ b/rmctrl/commands/lightoff @@ -0,0 +1,2 @@ +#!/bin/bash +curl -v -u lucka:h0gC3PMwSCXjJH8L "http://wattbox.mario/control.cgi?outlet=1&command=0" diff --git a/rmctrl/commands/lighton b/rmctrl/commands/lighton new file mode 100755 index 0000000..4aa5566 --- /dev/null +++ b/rmctrl/commands/lighton @@ -0,0 +1,2 @@ +#!/bin/bash +curl -v -u lucka:h0gC3PMwSCXjJH8L "http://wattbox.mario/control.cgi?outlet=1&command=1" diff --git a/rmctrl/commands/monitoroff b/rmctrl/commands/monitoroff new file mode 100755 index 0000000..17f58fb --- /dev/null +++ b/rmctrl/commands/monitoroff @@ -0,0 +1,6 @@ +#!/bin/bash +sudo wakeUltrawide.sh +curl -v -u lucka:h0gC3PMwSCXjJH8L "http://wattbox.mario/control.cgi?outlet=2&command=0" +curl -v -u lucka:h0gC3PMwSCXjJH8L "http://wattbox.mario/control.cgi?outlet=3&command=0" +sudo wakeUltrawide.sh + diff --git a/rmctrl/commands/monitoron b/rmctrl/commands/monitoron new file mode 100755 index 0000000..6effd72 --- /dev/null +++ b/rmctrl/commands/monitoron @@ -0,0 +1,3 @@ +#!/bin/bash +curl -v -u lucka:h0gC3PMwSCXjJH8L "http://wattbox.mario/control.cgi?outlet=2&command=1" +curl -v -u lucka:h0gC3PMwSCXjJH8L "http://wattbox.mario/control.cgi?outlet=3&command=1" diff --git a/rmctrl/commands/wega b/rmctrl/commands/wega new file mode 100755 index 0000000..81d0124 --- /dev/null +++ b/rmctrl/commands/wega @@ -0,0 +1,3 @@ +#!/bin/bash +cd ~/sh/rmctrl +./smartplug.sh hs100-wega.mario $1 diff --git a/rmctrl/hs100.sh b/rmctrl/hs100.sh new file mode 100755 index 0000000..3165a36 --- /dev/null +++ b/rmctrl/hs100.sh @@ -0,0 +1,157 @@ +#!/bin/bash +## +# Controls TP-LINK HS100,HS110, HS200 wlan smart plugs +# Tested with HS100 firmware 1.0.8 +# +# Credits to Thomas Baust for the query/status/emeter commands +# +# Author George Georgovassilis, https://github.com/ggeorgovassilis/linuxscripts + +echo args are $@ +ip=$1 +port=$2 +cmd=$3 + +# encoded (the reverse of decode) commands to send to the plug + +# encoded {"system":{"set_relay_state":{"state":1}}} +payload_on="AAAAKtDygfiL/5r31e+UtsWg1Iv5nPCR6LfEsNGlwOLYo4HyhueT9tTu36Lfog==" + +# encoded {"system":{"set_relay_state":{"state":0}}} +payload_off="AAAAKtDygfiL/5r31e+UtsWg1Iv5nPCR6LfEsNGlwOLYo4HyhueT9tTu3qPeow==" + +# encoded { "system":{ "get_sysinfo":null } } +payload_query="AAAAI9Dw0qHYq9+61/XPtJS20bTAn+yV5o/hh+jK8J7rh+vLtpbr" + +# the encoded request { "emeter":{ "get_realtime":null } } +payload_emeter="AAAAJNDw0rfav8uu3P7Ev5+92r/LlOaD4o76k/6buYPtmPSYuMXlmA==" + +# tools + +check_dependencies() { + command -v nc >/dev/null 2>&1 || { echo >&2 "The nc programme for sending data over the network isn't in the path, communication with the plug will fail"; exit 2; } + command -v base64 >/dev/null 2>&1 || { echo >&2 "The base64 programme for decoding base64 encoded strings isn't in the path, decoding of payloads will fail"; exit 2; } + command -v od >/dev/null 2>&1 || { echo >&2 "The od programme for converting binary data to numbers isn't in the path, the status and emeter commands will fail";} + command -v read >/dev/null 2>&1 || { echo >&2 "The read programme for splitting text into tokens isn't in the path, the status and emeter commands will fail";} + command -v printf >/dev/null 2>&1 || { echo >&2 "The printf programme for converting numbers into binary isn't in the path, the status and emeter commands will fail";} +} + +show_usage() { + echo Usage: $0 IP PORT COMMAND + echo where COMMAND is one of on/off/check/status/emeter/toggle + exit 1 +} + + +check_arguments() { + check_arg() { + name="$1" + value="$2" + if [ -z "$value" ]; then + echo "missing argument $name" + show_usage + fi + } + check_arg "ip" $ip + check_arg "port" $port + check_arg "command" $cmd +} + +send_to_plug() { + ip="$1" + port="$2" + payload="$3" + echo -n "$payload" | base64 --decode | nc -v $ip $port || echo couldn''t connect to $ip:$port, nc failed with exit code $? +} + +decode(){ + code=171 + offset=4 + input_num=`od -j $offset -An -t u1 -v | tr "\n" " "` + IFS=' ' read -r -a array <<< "$input_num" + args_for_printf="" + for element in "${array[@]}" + do + output=$(( $element ^ $code )) + args_for_printf="$args_for_printf\x$(printf %x $output)" + code=$element + done + printf "$args_for_printf" +} + +query_plug(){ + payload=$1 + send_to_plug $ip $port "$payload" | decode +} + +# plug commands + +cmd_print_plug_relay_state(){ + output=`send_to_plug $ip $port "$payload_query" | decode | egrep -oa 'relay_state":[0,1]' | egrep -o '[0,1]'` + if [[ $output -eq 0 ]]; then + echo OFF + elif [[ $output -eq 1 ]]; then + echo ON + else + echo Couldn''t understand plug response $output + fi +} + +cmd_print_plug_status(){ + query_plug "$payload_query" +} + +cmd_print_plug_consumption(){ + query_plug "$payload_emeter" +} + +cmd_switch_on(){ + send_to_plug $ip $port $payload_on > /dev/null +} + +cmd_switch_off(){ + send_to_plug $ip $port $payload_off > /dev/null +} + +cmd_switch_toggle() { + output=`cmd_print_plug_relay_state` + if [[ $output == OFF ]]; then + cmd_switch_on + elif [[ $output == ON ]]; then + cmd_switch_off + else + echo $output + fi +} + +## +# Main programme +## + + +check_dependencies +check_arguments + +case "$cmd" in + on) + cmd_switch_on + ;; + off) + cmd_switch_off + ;; + toggle) + cmd_switch_toggle + ;; + check) + cmd_print_plug_relay_state + ;; + status) + cmd_print_plug_status + ;; + emeter) + cmd_print_plug_consumption + ;; + *) + show_usage + ;; +esac diff --git a/rmctrl/inputtest.py b/rmctrl/inputtest.py new file mode 100755 index 0000000..ce18d1d --- /dev/null +++ b/rmctrl/inputtest.py @@ -0,0 +1,184 @@ +# Released by rdb under the Unlicense (unlicense.org) +# Based on information from: +# https://www.kernel.org/doc/Documentation/input/joystick-api.txt + +import os, struct, array, sys +from fcntl import ioctl + +# Iterate over the joystick devices. +print('Available devices:') + +for fn in os.listdir('/dev/input'): + if fn.startswith('js'): + print(' /dev/input/%s' % (fn)) + +# We'll store the states here. +axis_states = {} +button_states = {} + +# These constants were borrowed from linux/input.h +axis_names = { + 0x00 : 'x', + 0x01 : 'y', + 0x02 : 'z', + 0x03 : 'rx', + 0x04 : 'ry', + 0x05 : 'rz', + 0x06 : 'throttle', + 0x07 : 'rudder', + 0x08 : 'wheel', + 0x09 : 'gas', + 0x0a : 'brake', + 0x10 : 'hat0x', + 0x11 : 'hat0y', + 0x12 : 'hat1x', + 0x13 : 'hat1y', + 0x14 : 'hat2x', + 0x15 : 'hat2y', + 0x16 : 'hat3x', + 0x17 : 'hat3y', + 0x18 : 'pressure', + 0x19 : 'distance', + 0x1a : 'tilt_x', + 0x1b : 'tilt_y', + 0x1c : 'tool_width', + 0x20 : 'volume', + 0x28 : 'misc', +} + +button_names = { + 0x120 : 'trigger', + 0x121 : 'thumb', + 0x122 : 'thumb2', + 0x123 : 'top', + 0x124 : 'top2', + 0x125 : 'pinkie', + 0x126 : 'base', + 0x127 : 'base2', + 0x128 : 'base3', + 0x129 : 'base4', + 0x12a : 'base5', + 0x12b : 'base6', + 0x12f : 'dead', + 0x130 : 'a', + 0x131 : 'b', + 0x132 : 'c', + 0x133 : 'x', + 0x134 : 'y', + 0x135 : 'z', + 0x136 : 'tl', + 0x137 : 'tr', + 0x138 : 'tl2', + 0x139 : 'tr2', + 0x13a : 'select', + 0x13b : 'start', + 0x13c : 'mode', + 0x13d : 'thumbl', + 0x13e : 'thumbr', + + 0x220 : 'dpad_up', + 0x221 : 'dpad_down', + 0x222 : 'dpad_left', + 0x223 : 'dpad_right', + + # XBox 360 controller uses these codes. + 0x2c0 : 'dpad_left', + 0x2c1 : 'dpad_right', + 0x2c2 : 'dpad_up', + 0x2c3 : 'dpad_down', +} + +axis_map = [] +button_map = [] + +# Open the joystick device. +fn = f'/dev/input/{sys.argv[1]}' +print('Opening %s...' % fn) +jsdev = open(fn, 'rb') + +# Get the device name. +#buf = bytearray(63) +buf = array.array('B', [0] * 64) +ioctl(jsdev, 0x80006a13 + (0x10000 * len(buf)), buf) # JSIOCGNAME(len) +js_name = buf.tobytes().rstrip(b'\x00').decode('utf-8') +print('Device name: %s' % js_name) + +# Get number of axes and buttons. +buf = array.array('B', [0]) +ioctl(jsdev, 0x80016a11, buf) # JSIOCGAXES +num_axes = buf[0] + +buf = array.array('B', [0]) +ioctl(jsdev, 0x80016a12, buf) # JSIOCGBUTTONS +num_buttons = buf[0] + +# Get the axis map. +buf = array.array('B', [0] * 0x40) +ioctl(jsdev, 0x80406a32, buf) # JSIOCGAXMAP + +for axis in buf[:num_axes]: + axis_name = axis_names.get(axis, 'unknown(0x%02x)' % axis) + axis_map.append(axis_name) + axis_states[axis_name] = 0.0 + +# Get the button map. +buf = array.array('H', [0] * 200) +ioctl(jsdev, 0x80406a34, buf) # JSIOCGBTNMAP + +for btn in buf[:num_buttons]: + btn_name = button_names.get(btn, 'unknown(0x%03x)' % btn) + button_map.append(btn_name) + button_states[btn_name] = 0 + +print('%d axes found: %s' % (num_axes, ', '.join(axis_map))) +print('%d buttons found: %s' % (num_buttons, ', '.join(button_map))) + +# Main event loop +while True: + evbuf = jsdev.read(8) + if evbuf: + time, value, type, number = struct.unpack('IhBB', evbuf) + + if type & 0x80: + print("(initial)", end="") + + if type & 0x01: + button = button_map[number] + if button: + button_states[button] = value + if value: + print("%s pressed" % (button)) + + else: + print("%s released" % (button)) + + if type & 0x02: + axis = axis_map[number] + if axis: + fvalue = value / 32767.0 + axis_states[axis] = fvalue + #print("%s: %.3f" % (axis, fvalue)) + print(axis, fvalue) + + #IF STATEMENTS FOR DPAD + + if axis == 'hat0y' and fvalue == 1.0: # DPAD DOWN + os.system('echo dpad up') + if axis == 'hat0y' and fvalue == -1.0: # DPAD UP + os.system('echo dpad up') + + #IF STATEMENTS FOR C BUTTONS + + if axis == 'rz' and fvalue == 0.8453627124851222: # C LEFT + #os.system('~/rmctrl/smartplug.sh hs100-lights.mario off') + os.system('~/rmctrl/commands/lightoff &') + if axis == 'rz' and fvalue == -0.8247932370983001: # C RIGHT + #os.system('~/rmctrl/smartplug.sh hs100-lights.mario on') + os.system('~/rmctrl/commands/lighton &') + if axis == 'z' and fvalue == 0.8453627124851222: # C DOWN + #os.system('~/rmctrl/smartplug.sh hs100-monitors.mario off') + os.system('~/rmctrl/commands/monitoroff &') + os.system('ssh -i ~/.ssh/screenoff-key/screenoff lucka@x201t.mario &') + if axis == 'z' and fvalue == -0.8247932370983001: # C UP + #os.system('~/rmctrl/smartplug.sh hs100-monitors.mario on') + os.system('~/rmctrl/commands/monitoron &') diff --git a/rmctrl/joysticklightswitchTmux.yaml b/rmctrl/joysticklightswitchTmux.yaml new file mode 100755 index 0000000..bd79a02 --- /dev/null +++ b/rmctrl/joysticklightswitchTmux.yaml @@ -0,0 +1,10 @@ +session_name: 3-pane-split +windows: + - window_name: dev window + layout: tiled + shell_command_before: + - cd ~/rmctrl # run as a first command in all panes + panes: + - while true; do python3 inputtest.py js0; done # pane no. 1 + - while true; do python3 inputtest.py js1; done # pane no. 2 + - ./keepalive.sh # pane no. 3 diff --git a/rmctrl/keepalive.sh b/rmctrl/keepalive.sh new file mode 100755 index 0000000..1b1916b --- /dev/null +++ b/rmctrl/keepalive.sh @@ -0,0 +1,8 @@ +#!/bin/bash +while true +do +./smartplug.sh hs100-lights.mario check +./smartplug.sh hs100-monitors.mario check +sleep 2m +done + diff --git a/rmctrl/smartplug.sh b/rmctrl/smartplug.sh new file mode 100755 index 0000000..49534f1 --- /dev/null +++ b/rmctrl/smartplug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +cd /home/lucka/sh/rmctrl +./hs100.sh $1 9999 $2 & diff --git a/rofi/viewcam b/rofi/viewcam new file mode 100755 index 0000000..7dba6ee --- /dev/null +++ b/rofi/viewcam @@ -0,0 +1,2 @@ +#!/bin/bash +mpv av://v4l2:/dev/v4l/by-id/usb-Sonix_Technology_Co.__Ltd._Lenovo_FHD_Webcam_Audio_SN0001-video-index0 --profile=low-latency --untimed --demuxer-lavf-o-set=input_format=mjpeg -vf=hflip diff --git a/setup-keyboard-remap-poller.sh b/setup-keyboard-remap-poller.sh new file mode 100755 index 0000000..25499b7 --- /dev/null +++ b/setup-keyboard-remap-poller.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env bash + +# setup-keyboard-remap-poller.sh +# ============================= +# Installs a systemd user service that polls for keyboard plug-in / KVM switch events +# and runs ~/sh/keymaps.sh (your xmodmap stuff) when it detects a change. +# +# Why polling? Udev is too early / env broken for X11 tools in most cases. + +set -euo pipefail + +SERVICE_NAME="keyboard-remap-poller" +SERVICE_FILE="$HOME/.config/systemd/user/$SERVICE_NAME.service" +POLLER_SCRIPT="$HOME/.local/bin/keyboard-remap-poller.sh" +KEYMAPS_SCRIPT="$HOME/sh/keymaps.sh" + +if [[ ! -x "$KEYMAPS_SCRIPT" ]]; then + echo "Error: $KEYMAPS_SCRIPT not found or not executable." + echo "Make sure it exists and chmod +x it." + exit 1 +fi + +echo "Creating poller script: $POLLER_SCRIPT" + +mkdir -p "$(dirname "$POLLER_SCRIPT")" + +cat > "$POLLER_SCRIPT" << 'EOP' +#!/usr/bin/env bash +# keyboard-remap-poller.sh - checks for keyboard/input changes and runs keymaps.sh + +KEYMAPS_SCRIPT="$HOME/sh/keymaps.sh" +LOG_FILE="$HOME/.local/share/keyboard-remap.log" +LAST_COUNT_FILE="$HOME/.cache/keyboard-event-count" + +# Initial count of input devices (rough way to detect plug/unplug/KVM) +get_input_count() { + ls /dev/input/event* 2>/dev/null | wc -l +} + +last_count=$(cat "$LAST_COUNT_FILE" 2>/dev/null || echo "0") + +while true; do + current_count=$(get_input_count) + + if [[ "$current_count" != "$last_count" ]]; then + echo "$(date '+%Y-%m-%d %H:%M:%S') - Input device count changed ($last_count → $current_count). Running keymaps.sh" >> "$LOG_FILE" + + # Run your script in X session context + if [[ -n "${DISPLAY:-}" ]]; then + "$KEYMAPS_SCRIPT" >> "$LOG_FILE" 2>&1 + else + # Fallback: try common display :0 or :0.0 + DISPLAY=:0 XAUTHORITY="$HOME/.Xauthority" "$KEYMAPS_SCRIPT" >> "$LOG_FILE" 2>&1 || \ + DISPLAY=:0.0 XAUTHORITY="$HOME/.Xauthority" "$KEYMAPS_SCRIPT" >> "$LOG_FILE" 2>&1 + fi + + echo "$(date '+%Y-%m-%d %H:%M:%S') - keymaps.sh finished (exit code $?)" >> "$LOG_FILE" + echo "$current_count" > "$LAST_COUNT_FILE" + fi + + last_count="$current_count" + sleep 8 # Check every 8 seconds - low overhead +done +EOP + +chmod +x "$POLLER_SCRIPT" +echo "Poller script created." + +echo "Creating systemd user service: $SERVICE_FILE" + +mkdir -p "$(dirname "$SERVICE_FILE")" + +cat > "$SERVICE_FILE" << EOF +[Unit] +Description=Poll for keyboard plug-in / KVM events and run keymaps.sh +After=graphical-session.target + +[Service] +Type=simple +ExecStart=$POLLER_SCRIPT +Restart=always +RestartSec=5 + +[Install] +WantedBy=graphical-session.target +EOF + +echo "Service file created." + +echo "Enabling and starting the service (user level)..." +systemctl --user daemon-reload +systemctl --user enable --now "$SERVICE_NAME.service" + +echo "" +echo "=== Setup Done ===" +echo "The service is now running as your user." +echo "" +echo "Test it:" +echo " 1. Switch KVM or plug/unplug a keyboard" +echo " 2. Wait 10–20 seconds" +echo " 3. Check if your xmodmap changes applied (e.g. press your remapped keys)" +echo " 4. Look at log:" +echo " tail -f $HOME/.local/share/keyboard-remap.log" +echo "" +echo "If it doesn't trigger reliably:" +echo " - Increase sleep 8 → sleep 5 in $POLLER_SCRIPT" +echo " - Or if DISPLAY is wrong, edit the DISPLAY/XAUTHORITY lines" +echo "" +echo "To stop/disable:" +echo " systemctl --user stop $SERVICE_NAME.service" +echo " systemctl --user disable $SERVICE_NAME.service" +echo "" +echo "Enjoy your remaps without F10 every time!" diff --git a/tModLoader b/tModLoader new file mode 100755 index 0000000..427bb74 --- /dev/null +++ b/tModLoader @@ -0,0 +1,5 @@ +#!/bin/bash +cd /home/lucka/.steam/debian-installation/steamapps/common/tModLoader +/home/lucka/.steam/debian-installation/steamapps/common/tModLoader/start-tModLoader-FamilyShare.sh +#sleep 10 +#steam steam://rungameid/12579072071637663744 diff --git a/typeclipboard.sh b/typeclipboard.sh new file mode 100755 index 0000000..d193cc6 --- /dev/null +++ b/typeclipboard.sh @@ -0,0 +1,3 @@ +#!/bin/bash +sleep 0.9 +/bin/bash -c "sh -c 'sleep 0.2; xdotool type --delay $1ms \"\$(xclip -o -selection clipboard)\"'" diff --git a/ultrawide-monitor-split.sh b/ultrawide-monitor-split.sh new file mode 100755 index 0000000..92da8a5 --- /dev/null +++ b/ultrawide-monitor-split.sh @@ -0,0 +1,9 @@ +#!/bin/bash +xrandr --delmonitor m1 +xrandr --delmonitor m2 +#xrandr --setmonitor m1 1920/1x1080/1+640+0 DisplayPort-0 +#xrandr --setmonitor m1 1920/1x1080/1+0+0 DisplayPort-0 +xrandr --setmonitor m1 2880/1x1080/1+1600+0 DisplayPort-0 +xrandr --setmonitor m2 727/1x1080/1+640+0 none +#xrandr --setmonitor m2 1920/1x1080/1+2560+0 none +#xrandr --setmonitor m2 1920/1x1080/1+1920+0 none diff --git a/warpMouse.sh b/warpMouse.sh new file mode 100755 index 0000000..daccc14 --- /dev/null +++ b/warpMouse.sh @@ -0,0 +1,25 @@ +#!/bin/bash +focusWindowUnderMouse () { +xdotool windowactivate $(xdotool getmouselocation|sed "s/.*://") +} +case $1 in +1) +xdotool mousemove 800 400 +focusWindowUnderMouse +;; +2) +xdotool mousemove 2650 500 +focusWindowUnderMouse +;; +3) +xdotool mousemove 800 1600 +focusWindowUnderMouse +;; +4) +#xdotool mousemove 2560 1600 +xdotool mousemove 2180 1300 +focusWindowUnderMouse +;; +esac + + diff --git a/warpMouseAndWindow.sh b/warpMouseAndWindow.sh new file mode 100755 index 0000000..3267593 --- /dev/null +++ b/warpMouseAndWindow.sh @@ -0,0 +1,35 @@ +#!/bin/bash +focusWindowUnderMouse () { +xdotool windowactivate $(xdotool getmouselocation|sed "s/.*://") +} +maximizeWindow () { +wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz +} +unMaximizeWindow () { +wmctrl -r :ACTIVE: -b remove,maximized_vert,maximized_horz +} +moveWindowToMonitor () { +if [ "$(xprop -id $(xdotool getmouselocation --shell | awk -F= '/WINDOW/{print $2}') WM_CLASS | awk -F\" '{print $4}')" != "plasmashell" ]; then +unMaximizeWindow +xdotool getactivewindow windowsize 800 600 +xdotool mousemove $1 $2 +xdotool getactivewindow windowmove $1 $2 +maximizeWindow +fi +} + +case $1 in +1) +moveWindowToMonitor 800 400 +;; +2) +moveWindowToMonitor 2650 500 +;; +3) +moveWindowToMonitor 800 1600 +;; +4) +#moveWindowToMonitor 2560 1600 +moveWindowToMonitor 2180 1300 +;; +esac diff --git a/workspace/wl.sh b/workspace/wl.sh new file mode 100755 index 0000000..86ce8bd --- /dev/null +++ b/workspace/wl.sh @@ -0,0 +1,8 @@ +sudo apt install \ + libwayland-dev \ + libwayland-client++0 \ + libwayland-client0 \ + libwayland-client-extra++0 \ + libegl-dev \ + libtls-dev + diff --git a/ytmusicquick b/ytmusicquick new file mode 100755 index 0000000..8242214 --- /dev/null +++ b/ytmusicquick @@ -0,0 +1,70 @@ +#!/bin/bash +# dependencies: mpv youtube-dl fzf rofi/dmenu +# search videos and playlists on youtube and play them in mpv, without an API +# usage: +# yt asks for input in stdin, prompts using fzf +# yt search query takes input from the passed arg, prompts using fzf +# yt -r takes input and prompts using rofi ($guicmd) + +defcmd="fzf" +guicmd="rofi -dmenu -i" #uncomment next line for dmenu +#guicmd="dmenu -i -l 15" +promptcmd="$defcmd" +if [ -z "$*" ]; then + echo -n "Search: " + read -r query +else + case "$1" in + -r) query=$(echo | $guicmd -p "Youtube Search: ") + promptcmd="$guicmd -p Video:";; + *) query="$*";; + esac +fi +if [ -z "$query" ]; then exit; fi +# sanitise the query +query=$(sed \ + -e 's|+|%2B|g'\ + -e 's|#|%23|g'\ + -e 's|&|%26|g'\ + -e 's| |+|g'\ + <<< "$query") +# fetch the results with the $query and +# delete all escaped characters +response="$(curl -s "https://www.youtube.com/results?search_query=$query" |\ + sed 's|\\.||g')" +# if unable to fetch the youtube results page, inform and exit +if ! grep -q "script" <<< "$response"; then echo "unable to fetch yt"; exit 1; fi +# regex expression to match video and playlist entries from yt result page +vgrep='"videoRenderer":{"videoId":"\K.{11}".+?"text":".+?[^\\](?=")' +pgrep='"playlistRenderer":{"playlistId":"\K.{34}?","title":{"simpleText":".+?[^\"](?=")' +# grep the id and title +# return them in format id (type) title +getresults() { + grep -oP "$1" <<< "$response" |\ + awk -F\" -v p="$2" '{ print $1 "\t" p " " $NF}' +} +# get the list of videos/playlists and their ids in videoids and playlistids +videoids=$(getresults "$vgrep") +playlistids=$(getresults "$pgrep" "(playlist)") +# if there are playlists or videos, append them to list +[ -n "$playlistids" ] && ids="$playlistids\n" +[ -n "$videoids" ] && ids="$ids$videoids" +# url prefix for videos and playlists +videolink="https://youtu.be/" +playlink="https://youtube.com/playlist?list=" +# prompt the results to user infinitely until they exit (escape) +while true; do + echo "Choose Video/Playlist to play: " + choice=$(echo -e "$ids" | cut -d' ' -f2 | $promptcmd) # dont show id + if [ -z "$choice" ]; then exit; fi # if esc-ed then exit + id=$(echo -e "$ids" | grep -Fwm1 "$choice" | cut -d' ' -f1) # get id of choice + echo -e "$choice\t($id)" + echo "$videolink$id" + case $id in + # 11 digit id = video + ???????????) mpv "$videolink$id" --no-video --force-window=no;; + # 34 digit id = playlist + ??????????????????????????????????) mpv "$playlink$id" --no-video --force-window=no;; + *) exit ;; + esac +done