Skip to content

Instantly share code, notes, and snippets.

View jonathannerat's full-sized avatar

Jonathan Teran jonathannerat

  • Buenos Aires, Argentina
View GitHub Profile
@jonathannerat
jonathannerat / ddd
Last active February 27, 2023 01:33
OpenDoas wrapper in POSIX shell with support for multiple login attemps and (wip) su file editing (aka sudo -e)
#!/bin/sh
_errorf="$(mktemp -u)"
_files="$(mktemp -u)"
cleanup() {
[ -p "$_errorf" ] && rm "$_errorf"
[ -f "$_files" ] && rm "$_files"
}
@jonathannerat
jonathannerat / pavolume.pl
Last active January 31, 2020 19:14
PulseAudio volume manager script with custom max / min volume values
#!/bin/perl
# Manage volume with custom max / min values
# Sometimes I forget to turn down the volume after connecting my headphones
# and manage to considerably hurt my ears by doing so. This script helps me
# by limiting the max / min values the volume can reach.
# Bind your media +Vol and -Vol keys (and Mute if you want) to call this
# script with appropiate options. For example, my setup is like this:
# * +Vol > pavolume --max=50 +5% (prevents from going beyond 50% vol)
# * -Vol > pavolume --max=50 -5% (if volume was >> 50, it goes back to
@jonathannerat
jonathannerat / plank_launch.sh
Last active October 19, 2019 20:22
Launch Plank pinned items
#!/bin/bash
# Launch Plank pinned items
#
# receives a number and launches the corresponding pinned item in your plank dock
#
# Relies on gtk-launch to launch the .desktop file, which needs to be located
# in /usr/share/applications or $HOME/.local/share/applications
#
# You can use it to simulate the Meta+<Number> shortcut in Windows. To do this,
# create a shortcut for Win+1, Win+2, ..., Win+9, Win+0, with each of them executing
@jonathannerat
jonathannerat / ff-profile-per-activity.sh
Created August 7, 2019 14:36
This command starts firefox with a profile with the same name (converted to lowercase) as the current KDE activity
firefox -P `kactivities-cli --current-activity | cut -d' ' -f3 | tr '[:upper:]' '[:lower:]'` %u
@jonathannerat
jonathannerat / Microsoft.PowerShell_profile.ps1
Last active July 7, 2019 21:27
My powershell prompts (requires git & PSWriteColor module)
$env:VIRTUAL_ENV_DISABLE_PROMPT=1
function global:prompt {
Write-Host "`n"
if (Test-Path "$PWD\\.git"){
$branch = &git rev-parse --abbrev-ref HEAD
} else {
$branch = ""
}
@jonathannerat
jonathannerat / .bashrc
Last active October 3, 2019 18:11
My bash prompt
# adds git bash functions, e.g. get branch name
if [ -f "$HOME/.git-prompt.sh" ]; then
. ~/.git-prompt.sh
fi
# get the python virtualenv
function virtualenv_info(){
# Get Virtual Env
if [[ -n "$VIRTUAL_ENV" ]]; then
# Strip out the path and just leave the env name
@jonathannerat
jonathannerat / subl.reg
Created February 25, 2019 12:19
Create / Restore Sublime Text 3 context menu items
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text]
@="Edit with &Sublime Text"
"Icon"="C:\\Program Files\\Sublime Text 3\\sublime_text.exe,0"
"MuiVerb"="Edit with Sublime Text"
[HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text\command]
@="C:\\Program Files\\Sublime Text 3\\sublime_text.exe \"%1\""
@jonathannerat
jonathannerat / content.md
Last active October 24, 2020 15:59
Fix for corrupted screen and icons after suspend on systems with nvidia propietary drivers

This is done with an option when you load the module: modprobe nvidia NVreg_RegisterForACPIEvents=1 NVreg_EnableMSI=1

To automatically use this option, create a file named /etc/modprobe.d/50-nvidia.conf with the following content:

options nvidia NVreg_RegisterForACPIEvents=1 NVreg_EnableMSI=1

Restart your machine and now you can safely suspend and resume without screen corruption. In my case in 9 out of 10 suspend operations this fixes the screen corruption issue. Very rarely it still happens, but much less often than without this options.