lots of organization

This commit is contained in:
lucca
2026-06-29 13:58:46 -04:00
parent a8cf478c03
commit a151be6dfe
23 changed files with 6 additions and 429 deletions
+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]))
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)"'
+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