Skip to content

Instantly share code, notes, and snippets.

View polter-rnd's full-sized avatar

Pavel Artsishevsky polter-rnd

View GitHub Profile
@polter-rnd
polter-rnd / prime-offload.sh
Created August 11, 2023 17:23
Run app with NVIDIA PRIME using Bumblebee, e.g. ./prime-offload.sh xonotic
#!/bin/bash
NVIDIA_DEV=/dev/nvidia0
BUMBLEBEE_SOCKET=/var/run/bumblebee.socket
function init {
set -e
# Create named pipes for talking with bumblebee
local input output
@polter-rnd
polter-rnd / nvhda-fixup.sh
Created August 5, 2023 12:00
Fixup NVIDIA audio device power state when HDMI screen is attached or removed
#!/bin/bash
NVHDA_FILE="/proc/acpi/nvhda"
# Check all HDMI connections
while IFS= read -r; do
DRIVER=$(realpath "$(dirname "$REPLY")"/../device/driver)
if [ "$(basename "$DRIVER")" = "nvidia" ]; then
HDMI_CONNECTED=1
break
@polter-rnd
polter-rnd / wayland-launch.sh
Last active August 5, 2023 11:18
Launch Qt and Electron apps under pure Wayland with support for Flatpak
#!/bin/sh
platform_args=""
flatpak_args=""
# Check platform argument
case "$1" in
-electron)
platform=electron
;;
@polter-rnd
polter-rnd / git-ps1.sh
Created August 5, 2023 11:09
Bash prompt with Git and Python virtualenv 12 January, 2023
__ps1() {
local undo_color="\[\e[m\]"
local host_color="\[\e[38;5;153m\]"
local user_color="\[\e[38;5;172m\]"
if [ $EUID -eq 0 ]; then
user_color="\[\e[0;31m\]"
fi
echo "[$user_color\u$undo_color@$host_color\h$undo_color \W]"
}