added scripts folder to gitea

This commit is contained in:
lucca
2026-06-11 13:47:48 -04:00
commit f8130bd7d0
91 changed files with 1868 additions and 0 deletions
BIN
View File
Binary file not shown.
+44
View File
@@ -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"
Binary file not shown.
Executable
+19
View File
@@ -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
+10
View File
@@ -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
Binary file not shown.
+90
View File
@@ -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('<Return>', onclick)
textbox.bind('<KP_Enter>', onclick)
textbox.bind('<Control-BackSpace>', entry_ctrl_backspace)
textbox.bind('<Control-Key-a>', 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]))
+6
View File
@@ -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")
+6
View File
@@ -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 " )
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
bluetoothctl disconnect 9B:40:B0:7F:F9:9F
#bluetoothctl power off
notify-send "bluetooth headset disconnected"
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash
bluetoothctl power on
sleep 5
bluetoothctl connect 9B:40:B0:7F:F9:9F
notify-send "bluetooth headset connected"
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
ssh -J gpc xmonad-rad xset -display :0 dpms force off
+4
View File
@@ -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'")
+4
View File
@@ -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'
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
~/sh/gamingpc/vmswap.sh ltsc2021-nv-mp
~/sh/gamingpc/vmswap.sh tv-rad-vg-mp
+2
View File
@@ -0,0 +1,2 @@
ssh 192.168.0.2 sudo /sbin/poweroff
notify-send "gaming pc turned off"
+3
View File
@@ -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"
+3
View File
@@ -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"
+4
View File
@@ -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"
+3
View File
@@ -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"
+3
View File
@@ -0,0 +1,3 @@
ssh 192.168.0.2 virsh -c qemu:///system shutdown xmonad-rad
notify-send "powered off workstation VM"
+3
View File
@@ -0,0 +1,3 @@
ssh 192.168.0.2 virsh -c qemu:///system start xmonad-rad
notify-send "powered on workstation VM"
+2
View File
@@ -0,0 +1,2 @@
wakeonlan D0:50:99:C3:29:4D
notify-send "gaming pc turned on"
+2
View File
@@ -0,0 +1,2 @@
ssh 192.168.0.2 sudo /sbin/reboot
notify-send "gaming pc rebooted"
+5
View File
@@ -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"
+3
View File
@@ -0,0 +1,3 @@
import sys
from windowsVidModeFunctions import *
monProfile(sys.argv[1])
+39
View File
@@ -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")
+3
View File
@@ -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"
+1
View File
@@ -0,0 +1 @@
D:/Scripts/controlmymonitor/controlmymonitor.exe /SetValue HTJM400760 60 6
+3
View File
@@ -0,0 +1,3 @@
import sys
from windowsVidModeFunctions import *
monProfile(sys.argv[1])
+8
View File
@@ -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}")
+40
View File
@@ -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
Executable
+17
View File
@@ -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
Executable
+9
View File
@@ -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'
Executable
+16
View File
@@ -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
+26
View File
@@ -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
}
}
+23
View File
@@ -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
}
}
+1
View File
@@ -0,0 +1 @@
# Enter script code
+23
View File
@@ -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
}
}
@@ -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": "<f1>"
},
"filter": {
"regex": null,
"isRecursive": false
}
}
@@ -0,0 +1,3 @@
# Enter script code
content = clipboard.get_clipboard()
keyboard.send_keys(content)
+23
View File
@@ -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
}
}
+31
View File
@@ -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"
}
@@ -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"
}
+1
View File
@@ -0,0 +1 @@
if I recall correctly
@@ -0,0 +1 @@
luccapirovano@gmx.com
+22
View File
@@ -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()
View File
Executable
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
#=======================================================
exec nohup /home/lucka/sh/keymaps.sh &
Symlink
+1
View File
@@ -0,0 +1 @@
lgctl.sh
Executable
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
ssh gaming-win 'sc '$1' "Looking Glass (host)"'
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
scriptfolder=~/sh/monitormodes
cd $scriptfolder
bash ./$(ls . | rofi -dmenu -drun -p "Run: ")
+4
View File
@@ -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
+75
View File
@@ -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
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
mpv $(xclip -sel clip -o)
View File
+12
View File
@@ -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
+46
View File
@@ -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
+95
View File
@@ -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
Executable
+37
View File
@@ -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
Executable
+43
View File
@@ -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 150500 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
Executable
+48
View File
@@ -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)"
Executable
+47
View File
@@ -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)"
Executable
+46
View File
@@ -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"
Executable
+47
View File
@@ -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 50100 (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"
Executable
+44
View File
@@ -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"
Executable
+42
View File
@@ -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"
Executable
+43
View File
@@ -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 2060s)..."
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"
BIN
View File
Binary file not shown.
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
curl -v -u lucka:h0gC3PMwSCXjJH8L "http://wattbox.mario/control.cgi?outlet=1&command=0"
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
curl -v -u lucka:h0gC3PMwSCXjJH8L "http://wattbox.mario/control.cgi?outlet=1&command=1"
+6
View File
@@ -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
+3
View File
@@ -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"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
cd ~/sh/rmctrl
./smartplug.sh hs100-wega.mario $1
+157
View File
@@ -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
+184
View File
@@ -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 &')
+10
View File
@@ -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
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
while true
do
./smartplug.sh hs100-lights.mario check
./smartplug.sh hs100-monitors.mario check
sleep 2m
done
+3
View File
@@ -0,0 +1,3 @@
#!/bin/bash
cd /home/lucka/sh/rmctrl
./hs100.sh $1 9999 $2 &
Executable
+2
View File
@@ -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
+113
View File
@@ -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 1020 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!"
Executable
+5
View File
@@ -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
+3
View File
@@ -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)\"'"
+9
View File
@@ -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
Executable
+25
View File
@@ -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
+35
View File
@@ -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
+8
View File
@@ -0,0 +1,8 @@
sudo apt install \
libwayland-dev \
libwayland-client++0 \
libwayland-client0 \
libwayland-client-extra++0 \
libegl-dev \
libtls-dev
Executable
+70
View File
@@ -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