Skip to content

Instantly share code, notes, and snippets.

View AlexTMjugador's full-sized avatar
🐰
Likely going down a rabbit hole to get a neat thing

Alejandro González AlexTMjugador

🐰
Likely going down a rabbit hole to get a neat thing
View GitHub Profile
@AlexTMjugador
AlexTMjugador / 00-coolbits.conf
Created April 12, 2020 22:04
X server configuration for unlocking GPU fan control, voltage settings, clock settings and more in the nvidia-settings application. For more information, see https://download.nvidia.com/XFree86/Linux-x86_64/440.64/README/xconfigoptions.html#Coolbits.
Section "Device"
Identifier "nvidia"
Driver "nvidia"
Option "Coolbits" "31"
EndSection
@AlexTMjugador
AlexTMjugador / 99-sony-laptop
Created August 11, 2019 18:44
A script to configure the keyboard backlight and thermal control of a Sony laptop when pm-powersave is invoked. The laptop must be supported by the Linux sony-laptop driver.
#!/bin/sh
. "$PM_FUNCTIONS"
case "$1" in
true)
# Disable keyboard backlight, and set thermal control to silent
echo 0 > /sys/devices/platform/sony-laptop/kbd_backlight
echo silent > /sys/devices/platform/sony-laptop/thermal_control;;
false)
@AlexTMjugador
AlexTMjugador / parche-cryptsetup.patch
Created August 6, 2019 18:06
Arregla un retraso excesivo del apagado de un sistema Debian con sysvinit que ocurre cuando el sistema de ficheros raiz es un LV encriptado.
--- /usr/lib/cryptsetup/cryptdisks-functions 2019-08-06 19:59:34.836001686 +0200
+++ /usr/lib/cryptsetup/cryptdisks-functions-new 2019-08-06 19:59:19.824001638 +0200
@@ -186,6 +186,13 @@
log_action_end_msg 0
}
_do_stop_callback() {
+ # No intentar detener el volumen encriptado que contiene un LV
+ # donde está montado /. Como / no se puede desmontar, el LV no se
+ # puede desactivar limpiamente, y tampoco se puede parar el volumen
+ # encriptado. Lo importante es que el sistema de ficheros se
@AlexTMjugador
AlexTMjugador / comandos-control-volumen.sh
Last active August 2, 2019 18:00
Estos comandos, al ser ejecutados cuando se pulsa una tecla de control de volumen del teclado, restauran su funcionalidad en un entorno de escritorio de X compatible (p. ej. XFCE).
sh -c 'pactl set-sink-mute 0 toggle && ([ $(pactl list sinks | sed -n "/Mute: .*$/{s/^[[:space:]]*Mute: //;p};/^Sink #1$/q") = "no" ] && notify-send "Control de volumen" "Sonido no silenciado." --icon=audio-volume-medium || notify-send "Control de volumen" "Sonido silenciado." --icon=audio-volume-muted)'
sh -c 'pactl set-sink-volume 0 -2% && notify-send "Control de volumen" "Bajado volumen en un 2%." --icon=audio-volume-low'
sh -c 'pactl set-sink-volume 0 "+2%" && notify-send "Control de volumen" "Incrementado volumen en un 2%." --icon=audio-volume-high'
@AlexTMjugador
AlexTMjugador / autoconfigurar-backend-glx
Last active August 11, 2019 18:40
Un script y servicio de SystemV que configuran automáticamente el backend GLX a usar, teniendo en cuenta el adaptador gráfico que se está usando en mi portátil. Se asume que el paquete update-glx está disponible.
#!/bin/sh
# Sale del script mostrando un mensaje de error, con un determinado
# código de error.
salirConError() {
printf '\n'
echo "! $1" 1>&2
codigoError=$2
if [ -z "$codigoError" -o $codigoError -eq 0 ]; then
@AlexTMjugador
AlexTMjugador / countFileNames.c
Last active April 14, 2018 21:55
Retrieves the number of files that the user has selected in a window opened by the GetOpenFileName Win32 C API function. It assumes that the OFN_EXPLORER and OFN_ALLOWMULTISELECT flags are set.
size_t FilesSelected(OPENFILENAME ofn, size_t bufferSize)
{
// ofn.lpstrFile format:
// - If the user picks one file: folder\file\0\0
// - If the user picks several files: folder\0file1\0file2\0fileN\0\0
// This function assumes that input parameters are valid and is used just after GetOpenFileName returns with success.
size_t toret = 0;
BOOL bBufferEnd = FALSE;