Skip to content

Instantly share code, notes, and snippets.

View UndeadDevel's full-sized avatar

UndeadDevel

View GitHub Profile
@UndeadDevel
UndeadDevel / Run in focused qube
Last active February 13, 2024 01:27
QubesOS DVM caching mechanism + easy screenshots, open file manager & terminal in focused qube etc.
These three scripts together implement a QubesOS DVM caching mechanism,
allow easy screenshotting with the screenshot automatically copied to
the qube in focus,
launching a terminal or file manager in the qube in focus and
restarting qubes in focus, while also restarting their in-focus app and
moving it back to the workspace it was on!
@UndeadDevel
UndeadDevel / wifi-switch.sh
Last active January 29, 2024 19:52
QubesOS: switch WiFi on and off via keyboard shortcut
#!/bin/bash
qvm-run sys-net -- "if nmcli radio wifi | head -c1 | grep -E 'e'; then nmcli radio wifi off; else nmcli radio wifi on; fi"
# If the file /var/lib/NetworkManager/NetworkManager.state with the following content is created in sys-net's template, then WiFi is off by default on boot:
# [main]
# NetworkingEnabled=true
# WirelessEnabled=false
# WWANEnabled=true
@UndeadDevel
UndeadDevel / widget-click.sh
Created January 29, 2024 19:49
QubesOS: Trigger the keyboard-navigable Devices and Domains widgets with a keyboard shortcut
#!/bin/bash
# call with argument 'devices' or 'domains'
sleep 0.1
eval $(xdotool search --onlyvisible --name "qui-$1" getwindowgeometry --shell)
xdotool mousemove $X $Y click 1 mousemove restore
@UndeadDevel
UndeadDevel / qubes-menu.sh
Last active March 3, 2024 21:34
QubesOS: Open the new App Menu via a keyboard shortcut and move the mouse out of the way if necessary
#!/bin/bash
eval $(xdotool getmouselocation --shell)
xdotool mousemove 5 5
gdbus call --session --dest org.qubesos.appmenu --object-path "/org/qubesos/appmenu" --method org.freedesktop.Application.Activate "{}" &&
xdotool mousemove 100 125 mousemove 130 130 mousemove restore # fixes issue #9006
sleep 0.25
if [ $X -lt 720 ]; then
X=720 # prevent the mouse from selecting items in the app menu when opening it with the keyboard (issue #8789)
fi
@UndeadDevel
UndeadDevel / vm-give-default-network
Created January 29, 2024 19:45
QubesOS: give or remove default (viz. TOR for anon-qubes) network of the in-focus qube
#!/bin/bash
CUR_WIN_ID=$(xdotool getwindowfocus)
CUR_VM=$(xprop _QUBES_VMNAME -id $CUR_WIN_ID | cut -d \" -f 2)
if [[ "$CUR_VM" != *"not found"* ]];then
if ! qvm-prefs "$CUR_VM" netvm | head -c1 | grep -E '.';then
TEXT="TOR"
while read -r line
@UndeadDevel
UndeadDevel / change-CPU-performance-parameters
Created January 29, 2024 19:42
QubesOS: Switch between CPU governors
#!/bin/bash
# valid values: 0-255, lower means more performance-leaning
PERF=24
BAL=128 # don't modify this value without uncommenting the xenpm command below the first if-clause
PS=223
CUR_VAL=$(xenpm get-cpufreq-para | grep -E -m 1 -o energy_perf\ \[[0-9]+\] | tr -dc '0-9')
if [ "$CUR_VAL" -lt "$BAL" ]; then