Skip to content

Instantly share code, notes, and snippets.

@mekb-turtle
mekb-turtle / power
Created January 30, 2023 04:50
rofi power menu script
View power
#!/bin/sh
RES="$(rofi -dmenu -p "Power" <<< $'Shutdown\nRestart\nLog Out\nLock\nSuspend')"
if [[ "$RES" == "Shutdown" ]]; then /usr/local/sbin/do shutdown & disown; fi
if [[ "$RES" == "Restart" ]]; then /usr/local/sbin/do restart & disown; fi
if [[ "$1" == "logoutpid"* ]] && [[ "$RES" == "Log Out" ]]; then kill -- "$(sed 's/^logoutpid//'<<<"$1")"; fi
if [[ "$RES" == "Lock" ]]; then slock & disown; fi
if [[ "$RES" == "Suspend" ]]; then slock & /usr/local/sbin/do suspend1 & disown; fi
@mekb-turtle
mekb-turtle / openrgb
Created January 27, 2023 00:36
openrgb sdk server dinit service (replace /home/mekb/ with your home directory)
View openrgb
type = process
command = /usr/bin/openrgb --server --server-port 6742 -p default_noram --config /home/mekb/.config/OpenRGB/
smooth-recovery = true
logfile = /var/log/dinit/openrgb.log
waits-for = udev-settle
@mekb-turtle
mekb-turtle / pacman-apt
Last active September 28, 2022 02:54
Pacman-like front-end for apt
View pacman-apt
#!/usr/bin/bash
ROOT_PROGRAM=(sudo)
APT=(apt)
function pacman-run-apt(){
"${APT[@]}" "$@"
}
function pacman-run-apt-with-root(){
IFS=
if [[ "$(id -u)" == "0" ]]; then
"${APT[@]}" "$@"
@mekb-turtle
mekb-turtle / screenshot.sh
Created September 25, 2022 00:05
Screenshot utility
View screenshot.sh
#!/usr/bin/bash
screenshotmain(){
SCREENSHOT_DIR="/tmp/screenshots$(id -u)"
mkdir -p "$SCREENSHOT_DIR" || return
FORMAT="$(date +"%Y.%m.%d.%H.%M.%S")"
EXTENSION=png
MIME="image/png"
T=0
Z=1
A=
@mekb-turtle
mekb-turtle / proxy.js
Created September 9, 2022 13:05
Simple Node.js proxy
View proxy.js
#!/usr/bin/env node
const net = require("net");
const serverClientHost = "192.168.88.79"; // P->S
const serverClientPort = 22;
const proxyServerPort = 1337; // C->S
const proxyServer = new net.Server();
proxyServer.on("connection", (socket) => {
console.log("[C-P] new connection");
console.log(socket.address());
let serverClient = new net.Socket();
@mekb-turtle
mekb-turtle / liminetest.sh
Last active October 16, 2022 09:10
Test Limine configurations
View liminetest.sh
#!/usr/bin/bash
DIR=/tmp/liminetest
ISO_DIR=$DIR/isoroot
ISO=$DIR/out.iso
LIMINE_CONFIG=limine.cfg
LIMINE_DIR=limine.d # for adding extra fonts and stuff
LIMINE_BIN_DIR=/usr/share/limine
mkdir -pv "$DIR/" "$ISO_DIR/" "$ISO_DIR/$LIMINE_DIR/" && \
cp -v "${1-/boot/$LIMINE_CONFIG}" "$ISO_DIR/$LIMINE_CONFIG" || exit "$?"
cp -vr "${2-/boot/$LIMINE_DIR}"/* "$ISO_DIR/$LIMINE_DIR/"
@mekb-turtle
mekb-turtle / 5.18.7.config
Last active September 25, 2022 00:06
my Linux kernel config
View 5.18.7.config
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 5.18.7 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (GCC) 12.2.0"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=120200
CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=23900
@mekb-turtle
mekb-turtle / dhcpcd.conf
Created August 9, 2022 06:14
stop dhcpcd from overriding resolv.conf
View dhcpcd.conf
#controlgroup wheel
#hostname
#clientid
duid
persistent
vendorclassid
#option domain_name_servers, domain_name, domain_search
option classless_static_routes
option interface_mtu
option host_name
@mekb-turtle
mekb-turtle / tri.js
Last active July 11, 2022 13:15
Script to convert Blender .obj file to raw triangles - https://github.com/mekb-turtle/render
View tri.js
#!/usr/bin/env node
const fs = require("fs");
const file = fs.readFileSync(process.argv[2]).toString().split("\n").filter(e => !e.startsWith("#")).map(e => e.replace(/\s+/g, " "));
const scale = parseFloat(process.argv[3] || "1");
const color = process.argv[4] || "0xFFFFFF";
let vertices = [];
let faces = [];
const triangle = (arr) => {
if (arr.length < 3) return [ arr ];
let z = [];
@mekb-turtle
mekb-turtle / archwiki.sh
Last active June 25, 2022 05:24
script to search locally downloaded ArchWiki pages using dmenu
View archwiki.sh
#!/usr/bin/bash
HTML_CLIENT="librewolf"
AW="/usr/share/doc/arch-wiki/html/$(locale|grep "^LANG="|sed "s|^LANG=||;s|[_. :].*||")"
while true; do
if [[ -d "$AW" ]]; then
cd -- "$AW"
RES="$(printf "%s\n" Cancel * | dmenu -i)"
if [[ "$RES" == "Cancel" ]]; then exit; fi
AW="$AW/$RES"
else if [[ -f "$AW" ]]; then