Skip to content

Instantly share code, notes, and snippets.

View khromalabs's full-sized avatar

Rubén Gómez khromalabs

View GitHub Profile
@khromalabs
khromalabs / dpm
Last active April 2, 2023 18:58
DPM Dosbox Package Manager v.0.1
#!/bin/bash
set -eu
ME="${0##*/}"
PWDROM="/home/ruben/Juegos/dosbox/rom"
EXTROM=".tar.zst"
INFO="Dosbox Package Manager\nUse: $ME <action> [<rom_package>|<directory>]\nAvailable actions:\n launch <romfile>: Launch a rom package in dosbox\n list: List roms\n pack <directory>: Compress a game into a rom package\n unpack <romfile>: Decompresses a rom package into a directory\nLibrary location: \"$PWDROM\"\n"
if [ "$#" -lt 1 ]; then
echo -e "$INFO"
@khromalabs
khromalabs / pasinktoggle
Last active March 12, 2023 10:20
Pulseaudio quick audio output / sink switcher script, toggles when two outputs available, shows zenity list when more outputs available
#!/bin/bash
# Pulseaudio sink switcher
# Required commands: notify-send, zenity
SINK_LIST=$(pacmd list-sinks | grep -E "(index:|device.description)" | xargs -n2 -d'\n')
COUNT=$(echo "$SINK_LIST" | wc -l)
NEW_SINK=""
if [ $COUNT -eq 0 ]; then
notify-send "No audio sinks available"
elif [ $COUNT -eq 1 ]; then
notify-send "There's just one audio sink available"
@khromalabs
khromalabs / mysql3rdpartytunnel.sh
Last active June 5, 2020 17:09
Bash function to connect to a third party mysql server through a SSH connection
mysql3rdpartytunnel() {
SSH_HOST="<SSH HOST USE .SSH/CONFIG>"
MYSQL_HOST="<THIRD PARTY MYSQL SERVER>"
MYSQL_USER="<MYSQL SERVER USER>"
MYSQL_PASSWORD="<MYSQL PASSWORD>"
MYSQL_DEFAULT_SCHEMA=""
LOCALPORT=33061
SOCKET="/tmp/ssh-tunnel-$SSH_HOST-$RANDOM"
echo "Opening SSH socket $SOCKET..."
@khromalabs
khromalabs / pkt
Created May 31, 2020 15:50
Meta package manager (bash script) to easily mess with the most usual commands (add a package, remove a package, update, upgrade, list packages, etc) on supported systems: Archlinux, Manjaro, FreeBSD, Ubuntu, Amazon Linux and Gentoo. Easily extensible.
#!/bin/bash
# pkt - Package-management Kommon inTerface - 2009-2010 (c) Ruben "Khroma" Gomez
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@khromalabs
khromalabs / optiswitch
Last active May 31, 2020 15:51
Bash script to easily toggle in Nvidia Optimus based laptops between integrated and discrete graphics cards, compatible out of the box with Archlinux+LightDM systems
#!/bin/bash
# Nvidia official linux drivers and the bbswitch module are asumed to be installed, when using the integrated
# intel video card bbswitch will be used to turn the Nvidia card off for energy saving purposes. Reboot is needed to
# switch between modes.
# NOTE:
# /etc/lightdm.conf must contain this text, uncommented:
#
# [Seat:*]
# ... etc ...
@khromalabs
khromalabs / gcp
Last active May 31, 2020 15:54
Script en bash para automatizar mi trabajo diario en Git (texto en español)
#!/bin/bash
ROOT=/var/www/
SHOW_LAST_COMMITS=2
TOP_LEVEL=""
READ_PRE=">"
ECHO_PRE=" "