From 90f92d4c66853473476280315455cc49017cc1fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Jensen?= Date: Sun, 27 Apr 2025 21:57:27 +0200 Subject: [PATCH] init --- .bashrc | 1 + .config/sxhkd/sxhkdrc | 33 ++++++++ .profile | 27 +++++++ .shrc | 22 +++++ .xinitrc | 9 +++ .zshrc | 32 ++++++++ README.md | 14 ++++ bin/bbrep | 16 ++++ bin/bookmarks | 2 + bin/grab | 6 ++ bin/journal | 7 ++ bin/nest.sh | 2 + bin/pyrep | 20 +++++ bin/record-start | 2 + bin/record-stop | 2 + bin/selplumb | 9 +++ bin/vil | 182 ++++++++++++++++++++++++++++++++++++++++++ bin/web | 36 +++++++++ bin/xalpine | 3 + img/bg.png | Bin 0 -> 232 bytes 20 files changed, 425 insertions(+) create mode 100644 .bashrc create mode 100644 .config/sxhkd/sxhkdrc create mode 100644 .profile create mode 100644 .shrc create mode 100644 .xinitrc create mode 100644 .zshrc create mode 100644 README.md create mode 100755 bin/bbrep create mode 100755 bin/bookmarks create mode 100755 bin/grab create mode 100755 bin/journal create mode 100755 bin/nest.sh create mode 100755 bin/pyrep create mode 100755 bin/record-start create mode 100755 bin/record-stop create mode 100755 bin/selplumb create mode 100755 bin/vil create mode 100755 bin/web create mode 100755 bin/xalpine create mode 100644 img/bg.png diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..30411ed --- /dev/null +++ b/.bashrc @@ -0,0 +1 @@ +source ~/.shrc diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc new file mode 100644 index 0000000..ca6ff56 --- /dev/null +++ b/.config/sxhkd/sxhkdrc @@ -0,0 +1,33 @@ +# Reload functions +super + o + bookmarks +super + i + web https://duckduckgo.com +super + alt + n + setxkbmap no +super + alt + f + setxkbmap fi +super + ctrl + t + transset 0.7 +super + alt + k + xdotool mousemove_relative -- 0 -10 +super + alt + j + xdotool mousemove_relative 0 10 +super + alt + h + xdotool mousemove_relative -- -10 0 +super + alt + l + xdotool mousemove_relative 10 0 +super + alt + y + xdotool click 1 +super + alt + u + xdotool click 2 +super + alt + i + xdotool click 3 +super + alt + w + selplumb +super + ctrl + r + record-start +super + ctrl + x + record-stop +super + alt + g + grab diff --git a/.profile b/.profile new file mode 100644 index 0000000..d89ea5a --- /dev/null +++ b/.profile @@ -0,0 +1,27 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi diff --git a/.shrc b/.shrc new file mode 100644 index 0000000..0bd89ac --- /dev/null +++ b/.shrc @@ -0,0 +1,22 @@ +alias ls="ls --color=auto" +alias python="python3" +alias pip="pip3" +alias c="rlwrap clojure" +alias x=startx +alias fd=fdfind +alias ↓=vil +alias dmenu="dmenu -nf '#BBBBBB' -nb '#222222' -sb '#A02C4E' -sf '#EEEEEE' -fn terminus" +alias f="fzf --layout=reverse --height=40% --color=dark | xargs -r plumb" +alias a="fd | fzf --reverse --height 40% | xargs -r acme" +alias xterm="st" +alias dc="docker-compose" +alias w3m="w3m -o auto_image=FALSE" +alias less="less -R" +alias vi=vis +alias ll="ls -alG" + +export XDG_RUNTIME_DIR=/run/user/$(id -u) +export OPENER=plumb +export PLAN9=~/bin/`uname -m`/plan9port +export PATH=~/bin/`uname -m`:~/.local/bin:~/bin:$PATH:$PLAN9/bin + diff --git a/.xinitrc b/.xinitrc new file mode 100644 index 0000000..69d9699 --- /dev/null +++ b/.xinitrc @@ -0,0 +1,9 @@ +setxkbmap -layout no +sxhkd & +plumber & +feh --bg-tile ~/img/bg.png +while true; do + xsetroot -name "`date`" + sleep 60 +done & +exec dwm diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..f568a9a --- /dev/null +++ b/.zshrc @@ -0,0 +1,32 @@ +autoload -Uz promptinit +promptinit +prompt redhat + +setopt histignorealldups sharehistory + +HISTSIZE=5000 +SAVEHIST=5000 +HISTFILE=~/.zsh_history + +autoload -Uz compinit +compinit + +zstyle ':completion:*' auto-description 'specify: %d' +zstyle ':completion:*' completer _expand _complete _correct _approximate +zstyle ':completion:*' format 'Completing %d' +zstyle ':completion:*' group-name '' +zstyle ':completion:*' menu select=2 +eval "$(dircolors -b)" +zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} +zstyle ':completion:*' list-colors '' +zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s +zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' +zstyle ':completion:*' menu select=long +zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s +zstyle ':completion:*' use-compctl false +zstyle ':completion:*' verbose true + +zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' +zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' + +source ~/.shrc diff --git a/README.md b/README.md new file mode 100644 index 0000000..6e37f6f --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +Files and suggestions to make life a bit easier. + +# deps + +For Debian GNU/Linux based systems: + + apt install fzf dwm dmenu stterm python3 python3-webview tesseract-ocr tesseract-ocr-eng scrot xserver-xephyr ffmpeg xdotool podman redshift feh rlwrap w3m vis + +Additional deps not in Debian GNU/Linux stable: + +* [bb](https://babashka.org) +* [p9p](https://9fans.github.io/plan9port/) +* [nrepl-python-client](https://pypi.org/project/nrepl-python-client/) + diff --git a/bin/bbrep b/bin/bbrep new file mode 100755 index 0000000..63b112c --- /dev/null +++ b/bin/bbrep @@ -0,0 +1,16 @@ +#!/usr/bin/env bb +;; Based on: +;; https://book.babashka.org/#_interacting_with_an_nrepl_server +(ns nrepl-client + (:require [bencode.core :as b])) + +(defn nrepl-eval [port expr] + (println (clojure.string/trim expr)) + (let [s (java.net.Socket. "localhost" port) + out (.getOutputStream s) + in (java.io.PushbackInputStream. (.getInputStream s)) + _ (b/write-bencode out {"op" "eval" "code" expr}) + bytes (get (b/read-bencode in) "value")] + (println ";;" (String. bytes)))) + +(nrepl-eval 1667 (slurp *in*)) diff --git a/bin/bookmarks b/bin/bookmarks new file mode 100755 index 0000000..69de9b9 --- /dev/null +++ b/bin/bookmarks @@ -0,0 +1,2 @@ +#!/bin/sh +cat ~/bookmarks* | sort | uniq | dmenu -i -l 30 -sb "#303030" -fn terminus | awk -F ' | ' '{print $1}' | xargs -r plumb diff --git a/bin/grab b/bin/grab new file mode 100755 index 0000000..65e8d8c --- /dev/null +++ b/bin/grab @@ -0,0 +1,6 @@ +#!/bin/sh +FILE=/tmp/`dbus-uuidgen`.png +scrot -s $FILE +tesseract $FILE - --dpi 150 | xclip -i +rm $FILE + diff --git a/bin/journal b/bin/journal new file mode 100755 index 0000000..6551a2b --- /dev/null +++ b/bin/journal @@ -0,0 +1,7 @@ +#!/bin/sh +ENTRY=$@ +if [ -n "$ENTRY" ]; then + echo "`date -Is`\t$@" >> journal +fi +cat journal + diff --git a/bin/nest.sh b/bin/nest.sh new file mode 100755 index 0000000..5fdfe14 --- /dev/null +++ b/bin/nest.sh @@ -0,0 +1,2 @@ +#!/bin/sh +startx -- /usr/bin/Xephyr :1 diff --git a/bin/pyrep b/bin/pyrep new file mode 100755 index 0000000..9f8445f --- /dev/null +++ b/bin/pyrep @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# +# Requirements: nrepl-python-client +# + +import sys +import nrepl + +code = sys.stdin.read().strip() +print(code) +c = nrepl.connect("nrepl://localhost:1667") +c.write({"op": "eval", "code": code}) +response = c.read() +try: + print(";; " + response['value']) +except KeyError: + try: + print(";; ERROR: " + response['err']) + except KeyError: + pass diff --git a/bin/record-start b/bin/record-start new file mode 100755 index 0000000..1bff3fb --- /dev/null +++ b/bin/record-start @@ -0,0 +1,2 @@ +#!/bin/sh +ffmpeg -video_size 1920x1080 -framerate 60 -f x11grab -i :0 out-$(date +%s).mp4 diff --git a/bin/record-stop b/bin/record-stop new file mode 100755 index 0000000..abef8aa --- /dev/null +++ b/bin/record-stop @@ -0,0 +1,2 @@ +#!/bin/sh +ps aux | grep ffmpeg | grep x11 | awk '{print $2}' | xargs kill diff --git a/bin/selplumb b/bin/selplumb new file mode 100755 index 0000000..d27bb33 --- /dev/null +++ b/bin/selplumb @@ -0,0 +1,9 @@ +#!/bin/sh +TXT=$(xclip -o) +CWD=$(readlink /proc/$(pgrep -P $(xdotool getactivewindow getwindowpid))/cwd) +if [ -f "$CWD/$TXT" ]; then + plumb "$CWD/$TXT" +else + plumb "$TXT" +fi + diff --git a/bin/vil b/bin/vil new file mode 100755 index 0000000..e15e7a6 --- /dev/null +++ b/bin/vil @@ -0,0 +1,182 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# List System +# Copyright (C) 2011 Øyvind Jensen +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import cmd +import shelve +import os + +class CLI(cmd.Cmd): + + + header = 'Virtual Inventory Logger' + prompt = '> ' + storage = None + snd = None + filename = 'registry' + unablemsg = 'Unable to complete operation' + + def complete_most(self, text, line): + col = [] + for key in self.storage.keys(): + col.append(key) + for item in self.storage[key]: + col.append(item) + if text: + return [ + key for key in col + if key.startswith(text) + ] + else: + return col + + def log(self, line): + os.system('journal ' + line) + + def do_place(self, op): + 'USAGE: place ' + thinglocation = op.split() + thinglocation = self.strip(thinglocation) + if len(thinglocation) == 2: + location = thinglocation[1] + name = thinglocation[0] + try: + self.storage[location] + except KeyError: + self.storage[location] = [] + self.storage[location].append(name) + response = name + ' placed in ' + location + self.log(response) + else: + print(self.unablemsg) + + def complete_place(self, text, line, start_index, end_index): + return self.complete_most(text, line) + + def do_search(self, phrase): + 'USAGE: search ' + found = False + if len(phrase) > 0: + for location in self.storage: + for item in self.storage[location]: + if phrase in item or item in phrase: + print(item + ' is located in ' + location) + found = True + if not found: + print(phrase + ' is nowhere to be found') + print('Please get one and put it somewhere') + else: + print(self.unablemsg) + + def do_remove(self, op): + 'USAGE: remove ' + thinglocation = op.split() + thinglocation = self.strip(thinglocation) + if len(thinglocation) == 2: + location = thinglocation[1] + name = thinglocation[0] + try: + self.storage[location].remove(name) + if len(self.storage[location]) == 0: + self.storage.pop(location) + response = name + ' removed from ' + location + self.log(response) + except: + print(name + ' not found in ' + location) + else: + print(self.unablemsg) + + def complete_remove(self, text, line, start_index, end_index): + return self.complete_most(text, line) + + def do_move(self, op): + 'USAGE: move ' + moveop = op.split() + moveop = self.strip(moveop) + if len(moveop) == 3: + name = moveop[0] + fromloc = moveop[1] + toloc = moveop[2] + self.do_remove(name + ' ' + fromloc) + self.do_place(name + ' ' + toloc) + #print(name + ' moved from ' + fromloc + ' to ' + toloc) + else: + print(self.unablemsg) + + def complete_move(self, text, line, start_index, end_index): + return self.complete_most(text, line) + + def do_list(self, location): + 'USAGE: list ' + if len(location) > 0: + self.list_location(location) + else: + for onelocation in self.storage: + self.list_location(onelocation) + + def complete_list(self, text, line, start_index, end_index): + return self.complete_most(text, line) + + def do_journal(self, line): + 'USAGE: journal ' + os.system('journal ' + line) + + def strip(self, tostrip): + words = ['in', 'from', 'inside', 'into'] + for word in words: + if word in tostrip: + tostrip.remove(word) + return tostrip + + def list_location(self, location): + print(location) + try: + if self.storage[location] is not None: + for item in self.storage[location]: + print('\t' + item) + except KeyError: + print('There is no place like ' + location) + + def do_copyright(self, line): + print("Copyright (C) 2011- Øyvind Jensen") + + def do_credits(self, line): + print("Author:") + print("Øyvind Jensen") + print("oyvind.jensen@protonmail.com") + + def do_exit(self, line): + print('Be well..') + return True + + def __init__(self): + cmd.Cmd.__init__(self) + self.storage = shelve.open(self.filename, writeback = True) + + def do_EOF(self, line): + print() + return self.do_exit('') + + def complete(self, text, state): + """Add a whitespace after word completion""" + return cmd.Cmd.complete(self, text, state) + ' ' + + +if __name__ == "__main__": + CLI().cmdloop() + diff --git a/bin/web b/bin/web new file mode 100755 index 0000000..ab120df --- /dev/null +++ b/bin/web @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Minimal web browser +# Copyright (C) 2020 Øyvind Jensen +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +import sys +import webview + +evaluate = lambda window: window.evaluate_js(script) +window = webview.create_window('Web', sys.argv[1], text_select=True) +window.loaded += lambda: window.evaluate_js(""" +document.addEventListener("keydown", event => { + event.keyCode == 8? + history.back() + : + event.keyCode == 18? + location.reload() + : + null +}) +""") +webview.start(evaluate, window, http_server=True) diff --git a/bin/xalpine b/bin/xalpine new file mode 100755 index 0000000..2bb8a53 --- /dev/null +++ b/bin/xalpine @@ -0,0 +1,3 @@ +#!/bin/sh +xhost +"local:podman@" +podman run -it --rm -u 0 -e DISPLAY="$DISPLAY" -v /tmp/.X11-unix:/tmp/.X11-unix:rw alpine sh diff --git a/img/bg.png b/img/bg.png new file mode 100644 index 0000000000000000000000000000000000000000..8848edbc8da04b2d6a4d3856ae173ad3b7cbdd42 GIT binary patch literal 232 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqjKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgfvHfC-%)qU=tdVoTbC9V-A&iT2y zsd*&~&PAz-C8;S2<(VZJ3hti10pX2&;y^{to-U3d5|?Yw8}c1+;9)vwyW8>8|NpPp zV!JfFQZMtd&RMl<+snLt9!kcH9lVTu1?pRTb8g(tPjqUyA)sJ3