commit 4b912098810c18c667ce777ca2ca37bee562a40f from: Rafael M date: Sat May 2 19:17:52 2026 UTC local folder commit - 04fe984ec0f43c36ef3c9b6f9b67d8c7c9c7ade4 commit + 4b912098810c18c667ce777ca2ca37bee562a40f blob - 2860dbf9a247d1f406052e7f0aa39e8ca993a9ca blob + c3e263665103eb084429d7351a19429ff9aebf43 --- home/.cwmrc +++ home/.cwmrc @@ -10,9 +10,10 @@ htile 50 gap 24 0 0 0 sticky yes +autogroup # Colors -color activeborder "#345F0C" +color activeborder "#F2CA30" color inactiveborder "#323232" color urgencyborder "#7811A1" color groupborder "#789161" @@ -100,11 +101,11 @@ bind-key MC-Right window-resize-right-big # Tiling-like bind-key MC-h window-htile bind-key MC-v window-vtile -bind-key M-f window-fullscreen -bind-key M-m window-maximize -bind-key M-v window-vmaximize -bind-key M-h window-hmaximize -bind-key M-r window-hide +bind-key 4-f window-fullscreen +bind-key 4-m window-maximize +bind-key 4-v window-vmaximize +bind-key 4-h window-hmaximize +bind-key 4-r window-hide bind-key MS-m window-hide bind-key MC-m menu-window-hidden @@ -121,15 +122,15 @@ bind-key M-period group-cycle bind-key M-comma group-rcycle # Groups -bind-key M-1 group-only-1 -bind-key M-2 group-only-2 -bind-key M-3 group-only-3 -bind-key M-4 group-only-4 -bind-key M-5 group-only-5 -bind-key M-6 group-only-6 -bind-key M-7 group-only-7 -bind-key M-8 group-only-8 -bind-key M-9 group-only-9 +bind-key 4-1 group-only-1 +bind-key 4-2 group-only-2 +bind-key 4-3 group-only-3 +bind-key 4-4 group-only-4 +bind-key 4-5 group-only-5 +bind-key 4-6 group-only-6 +bind-key 4-7 group-only-7 +bind-key 4-8 group-only-8 +bind-key 4-9 group-only-9 bind-key MS-1 window-movetogroup-1 bind-key MS-2 window-movetogroup-2 @@ -142,11 +143,11 @@ bind-key MS-8 window-movetogroup-8 bind-key MS-9 window-movetogroup-9 bind-key M-a group-toggle-all -bind-key M-w menu-window -bind-key M-e menu-cmd -bind-key M-x menu-exec -bind-key M-s menu-ssh -bind-key M-q menu-exec-wm +#bind-key M-w menu-window +#bind-key M-e menu-cmd +#bind-key M-x menu-exec +#bind-key M-s menu-ssh +#bind-key M-q menu-exec-wm # Mouse blob - 34a657f83eb9ce1847f1f75ebcec5d746443a886 (mode 755) blob + /dev/null --- home/.local/bin/dmenumon.sh +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/ksh - -# ----------------------------- -# OpenBSD X11 display selector -# ----------------------------- - -export DISPLAY=:0 -export XAUTHORITY="${HOME}/.Xauthority" - -LOG="$HOME/.xrandr-monitor.log" - -log() { - print -- "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> "$LOG" -} - -CHOICE="$1" - -if [[ -z "$CHOICE" ]]; then - CHOICE=$(printf '%s\n' "DP" "EXT" "Dual" | dmenu -p Monitor) -fi - -log "Selected: $CHOICE" - -INTERNAL="eDP1" - -# Detect first connected external display -get_external() { - xrandr | awk ' - / connected/ && - $1 !~ /^'"$INTERNAL"'$/ && - $1 !~ /^VIRTUAL/ { - print $1; exit - }' -} - -# Force re-probe (helps DP docks) -reprobe() { - log "Reprobing outputs" - xrandr --auto >/dev/null 2>&1 - sleep 0.5 -} - -# Wait up to ~5 seconds for external display -wait_for_external() { - i=0 - while [[ $i -lt 10 ]]; do - EXT=$(get_external) - [[ -n "$EXT" ]] && return 0 - reprobe - sleep 0.3 - i=$((i + 1)) - done - return 1 -} - -case "$CHOICE" in - DP) - log "Internal display only" - EXT=$(get_external) - xrandr \ - --output "$INTERNAL" --preferred --primary \ - ${EXT:+--output "$EXT" --off} - ;; - - EXT) - log "External display only" - if wait_for_external; then - log "Using external output: $EXT" - xrandr \ - --output "$INTERNAL" --off \ - --output "$EXT" --preferred --primary - else - log "ERROR: No external monitor detected" - exit 1 - fi - ;; - - Dual) - log "Dual display mode" - if wait_for_external; then - log "Using external output: $EXT" - xrandr \ - --output "$EXT" --preferred --pos 0x0 \ - --output "$INTERNAL" --preferred --pos 3840x0 --primary - else - log "ERROR: No external monitor detected" - exit 1 - fi - ;; - - *) - log "Invalid option" - exit 1 - ;; -esac - -if pgrep -x herbstluftwm >/dev/null; then - sleep 0.3 - herbstclient detect_monitors >/dev/null 2>&1 || \ - herbstclient reload >/dev/null 2>&1 -fi - -log "Done" - blob - dc9b1ab54b93e03d4cbc6e03e59cea855ef3c0d8 (mode 755) blob + /dev/null --- home/.local/bin/screenshot-menu.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -# Based on https://git.smithies.me.uk/openbsd-desktop-dotfiles/tree/.local/bin/screenshot.sh - -dir="$HOME/Pictures/Screenshots" -mkdir -p "$dir" -img_path="$dir/$(date +%Y-%m-%d_%H-%M-%S).png" - -copy_to_clipboard() { - xclip -selection clipboard -t image/png -i "$1" -} - -current_screen() { - set -- $(xrandr --current | awk '/ connected/ {print $3}' | grep '^[0-9]') - geom="$1" - - MONW=$(echo "$geom" | awk -F '[x+]' '{print $1}') - MONH=$(echo "$geom" | awk -F '[x+]' '{print $2}') - MONX=$(echo "$geom" | awk -F '[x+]' '{print $3}') - MONY=$(echo "$geom" | awk -F '[x+]' '{print $4}') -} - -take_action() { - case "$1" in - "screen") - current_screen - maim -g "${MONW}x${MONH}+${MONX}+${MONY}" "$img_path" - copy_to_clipboard "$img_path" - printf '%s\n' "$img_path" - ;; - "region") - maim -s "$img_path" - copy_to_clipboard "$img_path" - printf '%s\n' "$img_path" - ;; - "window") - maim -i "$(xdotool getactivewindow)" "$img_path" - copy_to_clipboard "$img_path" - printf '%s\n' "$img_path" - ;; - "clipboard") - current_screen - maim -g "${MONW}x${MONH}+${MONX}+${MONY}" | \ - xclip -selection clipboard -t image/png - printf 'Copied screenshot to clipboard\n' - ;; - *) - exit 1 - ;; - esac -} - -if [ -n "$1" ]; then - take_action "$1" - exit 0 -fi - -choice=$(printf '%s\n' \ - "screen" \ - "region" \ - "window" \ - "clipboard" | - rofi -dmenu -i -p "screenshot") - -[ -n "$choice" ] || exit 0 -take_action "$choice" blob - 46d0ae3991b1dc8d802dec166e71269c2495b716 (mode 644) blob + /dev/null --- home/.local/bin/tailscaled +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/ksh -# -# $OpenBSD: tailscaled,v 0.1 $ - -daemon="/usr/local/sbin/tailscaled --state=/var/db/tailscale/tailscaled.state --socket=/var/run/tailscale/tailscaled.sock" -daemon_flags="--port 0 --tun tun0" - -rc_bg="YES" -rc_reload="NO" - -. /etc/rc.d/rc.subr - -# these have to be placed below the above rc.subr sourcing so that they override -# default value is: pexp="${daemon}${daemon_flags:+ ${daemon_flags}}" -pexp="tailscaled" - -rc_start() { - # default value is: ${rcexec} "${daemon} ${daemon_flags} ${_bg}" - # ${_bg} gets replaced with '&' if rc_bg=YES - - ${rcexec} "${daemon} ${daemon_flags} 2>&1 | logger -t tailscaled ${_bg}" -} - -rc_stop() { - # default value is: pkill -xf "${pexp}" - - ${rcexec} "${daemon} --cleanup ${daemon_args} 2>&1 | logger -t tailscaled" - pkill -xf "${pexp}" -} - -rc_check() { - # default value is: pgrep -q -xf "${pexp}" - - pgrep -q -x ${pexp} -} - -rc_cmd $1 blob - 8351ad08b366f1328146e4fc7f6aae247c5326e1 (mode 755) blob + /dev/null --- home/.local/bin/termbar +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/ksh -# -# Some kind of status bar for XTerm -# ./termbar -# xterm -e "./termbar" & - -PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin" - -# Restart it-self if it get a SIGHUP -trap 'echo ""; exec $0' HUP - -# Reset the terminal on exit -trap 'tput cnorm; exit 1' INT QUIT TERM - -# Get the number of columns -_cols=$(tput columns) - -# Use the terminal colors -_rset="\033[0m" # Reset / Normal formatting -_hide="\033[2m" # Decrease intensity -_hlty="\033[32m" # Green foreground -_alrt="\033[31m" # Red foreground -_warn="\033[33m" # Yellow foreground -_actv="\033[34m" # Blue foreground -_none="\033[35m" # Magenta foreground -_norm="\033[39m" # Magenta foreground - -# (Nerd Fonts) icons and colors used in functions -set -A _bat "${_norm}" "${_warn}" "${_alrt}" -set -A _snl "${_norm}" "${_warn}" "${_alrt}" "${_none}" -set -A _pwr "${_actv}" -set -A _net "eth" "wlan" -set -A _nic "em0" "urtwn0" -set -A _vol "q" "w" ":" - -# Functions that gather and print things -function bat { - (( $(apm -a) == 1 )) && _status=${_pwr[0]} \ - || _status=${_bat[$(apm -b)]} - echo -n "bat: ${_status}$(apm -l)%${_norm}" -} - -function cal { - [[ $(date "+%H") -ge 6 && $(date "+%H") -le 22 ]] \ - && echo -n "${_norm}" \ - || echo -n "${_warn}" - echo -n $(date '+%a. %Y/%m/%d %H:%M')${_norm} -} - -function cpu { - echo -n "cpu: $(sysctl -n hw.sensors.cpu0.temp0 | cut -d '.' -f 1)°C" -} - -function kbd { - #echo -n " $(setxkbmap -query | awk '/^layout:/ { print $2 }')" - setxkbmap -query | awk '/^layout:/ { printf "%s %s", "x", $2 }' -} - -function net { - [[ -z "$(ifconfig ${_nic[0]} | grep 'status: no carrier')" ]] \ - && (echo -n ${_net[0]} ; return) - _signal=$( ifconfig ${_nic[1]} | awk '/ieee80211:/ { sub(/dBm/, "", $8); print $8 }') - # Decide index: 0 = norm, 1 = warm, 2 = alert - if [[ -z $_signal ]]; then - idx=3 - _signal="󰲜 " - elif (( _signal >= -65 )); then - idx=0 - elif (( _signal >= -75 )); then - idx=1 - else - idx=2 - fi - echo "net: ${_snl[$idx]}${_signal}${_norm}" -} - -function vol { - _v=$(sndioctl -n output.level | awk '{ print int($0*100) '}) - [[ $(sndioctl -n input.mute) -eq 1 ]] \ - && echo -n "${_norm}M${_norm}" \ - || echo -n "${_warn}${_norm}" - [[ $(sndioctl -n output.mute) -eq 1 ]] \ - && echo -n "" \ - || echo -n "${_vol[$(($_v*3/101))]}" - echo -n "$_v%" -} - -function win { - _grp=$(xprop -root 32c '\t$0' _NET_CURRENT_DESKTOP | cut -f 2) - _wid=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) - [[ "$_wid" == "0x0" ]] && _win="" || \ - _win=$(xprop -id $_wid '\t$0' _NET_WM_NAME | awk -F '"' '{ print $2 }') - printf "${_hide}[ $_grp ]${_rset} %s" "${_win}" -} - -tput civis # Hide cursor - -#((_middle=$_cols/2 )) -_col_data=260 -_col_time=296 -_connected_displays=$(xrandr --query | grep " connected" | wc -l) -if [[ $_connected_displays -eq 1 ]]; then - _col_data=105 - _col_time=137 -fi - -while true; do -# tput cup 0 100 - tput cup 0 $_col_data - printf "%-40.98s" "$(cpu) $(bat) $(vol) $(net)" - - #_r=$(cal) - #((_pos=$_cols - ${#_r})) - # tput cup 0 265 - tput cup 0 $_col_time - printf "%20.100s" "$(cal)" - - for i in $(jot 15 1); do - tput cup 0 0 - printf "%-100.100s" "$(win)" - sleep .3 - done - -done - -tput cnorm # Show cursor - -#EOF - blob - 88e7659d74ec6177756837713ddf9def36d0acdb blob + 5a0ea89cd4349602a01e54295acbcbab63558620 --- home/.profile +++ home/.profile @@ -35,3 +35,22 @@ function git_branch { # Set the PS1 variable with Dracula colors PS1="${GREEN}${BOLD}\u${RESET}@${CYAN}\h${RESET}:${PURPLE}\w${RESET}\$(git_branch)${YELLOW}\n$ ${RESET}" + +if [ -n "$TMUX" ]; then + lv() { + tmux split-window -h less "$@" + } + + ev() { + tmux split-window -h mg "$@" + } + + lh() { + tmux split-window -v less "$@" + } + + eh() { + tmux split-window -v mg "$@" + } +fi + blob - c7ac2034027db11bb8641a99db6a820f49eac917 blob + 8856ab14ccc6e29005bcf8ca3ad83380ec643933 --- makefile +++ makefile @@ -1,6 +1,6 @@ DOTFILES_DIR := $(HOME)/.dotfiles -.PHONY: home packages +.PHONY: home packages local home: @echo ">> Stowing home dotfiles into $(HOME)" @@ -9,6 +9,12 @@ home: --restow \ home +local: + @echo ">> Stowing local dotfiles into $(HOME)" + cd "$(DOTFILES_DIR)" && stow --verbose --target="$(HOME)" \ + --restow \ + local + packages: @echo ">> Packages" cd $(DOTFILES_DIR) && sh pkg_mgmt.sh blob - /dev/null blob + 34a657f83eb9ce1847f1f75ebcec5d746443a886 (mode 755) --- /dev/null +++ local/.local/bin/dmenumon.sh @@ -0,0 +1,104 @@ +#!/bin/ksh + +# ----------------------------- +# OpenBSD X11 display selector +# ----------------------------- + +export DISPLAY=:0 +export XAUTHORITY="${HOME}/.Xauthority" + +LOG="$HOME/.xrandr-monitor.log" + +log() { + print -- "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> "$LOG" +} + +CHOICE="$1" + +if [[ -z "$CHOICE" ]]; then + CHOICE=$(printf '%s\n' "DP" "EXT" "Dual" | dmenu -p Monitor) +fi + +log "Selected: $CHOICE" + +INTERNAL="eDP1" + +# Detect first connected external display +get_external() { + xrandr | awk ' + / connected/ && + $1 !~ /^'"$INTERNAL"'$/ && + $1 !~ /^VIRTUAL/ { + print $1; exit + }' +} + +# Force re-probe (helps DP docks) +reprobe() { + log "Reprobing outputs" + xrandr --auto >/dev/null 2>&1 + sleep 0.5 +} + +# Wait up to ~5 seconds for external display +wait_for_external() { + i=0 + while [[ $i -lt 10 ]]; do + EXT=$(get_external) + [[ -n "$EXT" ]] && return 0 + reprobe + sleep 0.3 + i=$((i + 1)) + done + return 1 +} + +case "$CHOICE" in + DP) + log "Internal display only" + EXT=$(get_external) + xrandr \ + --output "$INTERNAL" --preferred --primary \ + ${EXT:+--output "$EXT" --off} + ;; + + EXT) + log "External display only" + if wait_for_external; then + log "Using external output: $EXT" + xrandr \ + --output "$INTERNAL" --off \ + --output "$EXT" --preferred --primary + else + log "ERROR: No external monitor detected" + exit 1 + fi + ;; + + Dual) + log "Dual display mode" + if wait_for_external; then + log "Using external output: $EXT" + xrandr \ + --output "$EXT" --preferred --pos 0x0 \ + --output "$INTERNAL" --preferred --pos 3840x0 --primary + else + log "ERROR: No external monitor detected" + exit 1 + fi + ;; + + *) + log "Invalid option" + exit 1 + ;; +esac + +if pgrep -x herbstluftwm >/dev/null; then + sleep 0.3 + herbstclient detect_monitors >/dev/null 2>&1 || \ + herbstclient reload >/dev/null 2>&1 +fi + +log "Done" + blob - /dev/null blob + 120b4260f465df7c9152b27e48f99967593936b1 (mode 755) --- /dev/null +++ local/.local/bin/gpg-secret-get @@ -0,0 +1,17 @@ +#!/bin/sh + +file="$1" +key="$2" + +[ -n "$file" ] && [ -n "$key" ] || { + echo "usage: $0 FILE.gpg KEY" >&2 + exit 1 +} + +[ -f "$file" ] || { + echo "error: file not found: $file" >&2 + exit 1 +} + +gpg --quiet --batch --decrypt "$file" 2>/dev/null | + awk -F= -v k="$key" '$1 == k { sub(/^[^=]*=/, ""); print; exit }' blob - /dev/null blob + 9f585ce27546698dc5b74b2b1370f7aafa2bbdaa (mode 755) --- /dev/null +++ local/.local/bin/mail-secret.sh @@ -0,0 +1,4 @@ +#!/bin/sh +exec "$HOME/.local/bin/gpg-secret-get" \ + "$HOME/.config/mail/mail-secrets.gpg" \ + "$1" blob - /dev/null blob + bedb527fb99d24d9eaf40bd3ae775ed2396b0de5 (mode 755) --- /dev/null +++ local/.local/bin/panel-cwm.sh @@ -0,0 +1,158 @@ +#!/bin/sh +# cwm-compatible lemonbar panel for OpenBSD. +# This intentionally does not use herbstclient; cwm has no herbstclient-like IPC. + +trap 'pkill -P $$ lemonbar 2>/dev/null; pkill -P $$ lemonbar-xft 2>/dev/null; exit' INT TERM EXIT + +monitor="${1:-0}" + +# --- geometry --- +# Prefer xrandr for multi-monitor geometry, fall back to full root dimensions. +geometry_from_xrandr() { + xrandr --current 2>/dev/null | awk -v mon="$monitor" ' + / connected/ { + # geometry token looks like 1920x1080+0+0 + for (i = 1; i <= NF; i++) { + if ($i ~ /^[0-9]+x[0-9]+\+[0-9]+\+[0-9]+/) { + geom=$i + split(geom, a, /[x+]/) + count++ + if (count-1 == mon) { + printf "%s %s %s %s\n", a[3], a[4], a[1], a[2] + exit + } + } + } + } + ' +} + +geometry_from_xdpyinfo() { + xdpyinfo 2>/dev/null | awk '/dimensions:/ { split($2, d, "x"); printf "0 0 %s %s\n", d[1], d[2]; exit }' +} + +set -- $(geometry_from_xrandr) +if [ $# -ne 4 ]; then + set -- $(geometry_from_xdpyinfo) +fi + +x="${1:-0}" +y="${2:-0}" +w="${3:-1024}" +h="${4:-768}" + +# --- DPI-aware sizing --- +base_dpi=96 +base_font=7 + +dpi=$(xrdb -query 2>/dev/null | awk '/Xft.dpi/ {print int($2)}') +[ -z "$dpi" ] && dpi=$base_dpi + +font_size=$(( dpi * base_font / base_dpi )) +[ "$font_size" -lt 7 ] && font_size=7 +panel_height=$(( font_size * 2 )) + +font="NotoMono Nerd Font:size=$font_size" + +# --- colors --- +bg="#1e1e2e" +fg="#cdd6f4" +CLR_OK="#98c379" +CLR_NORMAL="#61afef" +CLR_URGENT="#e06c75" +CLR_EMPTY="#5c6370" +CLR_BG_FOCUS="#2c323c" + +# cwm has groups but no simple external status API like herbstclient tag_status. +# So this is a static group strip. Your cwm keybindings still control groups. +groups() { + sep=" | " + first=1 + for n in 1 2 3 4 5 6 7 8 9; do + [ "$first" -eq 1 ] && first=0 || printf '%s' "$sep" + printf '%%{F%s}%s%%{F-}' "$CLR_EMPTY" "$n" + done +} + +active_window_id() { + xprop -root _NET_ACTIVE_WINDOW 2>/dev/null | awk -F'window id # ' 'NF > 1 {print $2}' +} + +title() { + id=$(active_window_id) + [ -z "$id" ] && return + [ "$id" = "0x0" ] && return + + t=$(xprop -id "$id" _NET_WM_NAME 2>/dev/null | sed 's/^.*= //; s/^"//; s/"$//') + if [ -z "$t" ] || [ "$t" = "not found." ]; then + t=$(xprop -id "$id" WM_NAME 2>/dev/null | sed 's/^.*= //; s/^"//; s/"$//') + fi + [ -z "$t" ] || [ "$t" = "not found." ] && return + printf ' %.60s' "$t" +} + +battery() { + [ "$(apm -b 2>/dev/null)" = "4" ] && return + + batt=$(apm -l 2>/dev/null) + charging=$(apm -a 2>/dev/null) + + color="#efefef" + [ -z "$batt" ] && { printf '%%{F#888888}bat: N/A%%{F-}'; return; } + [ "$batt" -ge 99 ] && batt="++" + [ "$batt" != "++" ] && [ "$batt" -ge 95 ] && color="$CLR_OK" + [ "$batt" != "++" ] && [ "$batt" -le 60 ] && color="#ffaf00" + [ "$batt" != "++" ] && [ "$batt" -le 15 ] && color="$CLR_URGENT" + [ "$charging" = 1 ] && color="#80dfff" + + printf '%%{F%s}bat: %s%%%%{F-}' "$color" "$batt" +} + +clock() { + date '+%m-%d %H:%M' +} + +temp() { + temp=$(sysctl -n hw.sensors.cpu0.temp0 2>/dev/null | cut -d'.' -f1) + [ -z "$temp" ] && { printf '%%{F#888888}temp: N/A%%{F-}'; return; } + + color="#ff0000" + [ "$temp" -lt 70 ] && color="$CLR_URGENT" + [ "$temp" -lt 50 ] && color="$CLR_OK" + + printf '%%{F%s}temp: %s°C%%{F-}' "$color" "$temp" +} + +volume() { + mute=$(sndioctl -n output.mute 2>/dev/null) || return + if [ "$mute" = 1 ]; then + printf '%%{F#ff5555}%%{+u}vol: -%%{-u}%%{F-}' + return + fi + + level=$(sndioctl -n output.level 2>/dev/null) || return + if [ "$level" = "1.000" ]; then + printf 'vol: ++' + return + fi + + frac=${level#0.} + frac=${frac}00 + vol=${frac%${frac#??}} + + printf 'vol: %s%%' "$vol" +} + +while :; do + right="%{O10}$(volume)%{O10}$(temp)%{O10}$(battery)%{O10}$(clock)%{O10}" + + printf '%%{l}%s |> %s%%{r}%s\n' \ + "$(groups)" \ + "$(title)" \ + "$right" + + sleep 1 || break +done | lemonbar-xft \ + -g "${w}x${panel_height}+${x}+${y}" \ + -B "$bg" -F "$fg" \ + -f "$font" blob - /dev/null blob + dc9b1ab54b93e03d4cbc6e03e59cea855ef3c0d8 (mode 755) --- /dev/null +++ local/.local/bin/screenshot-menu.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# Based on https://git.smithies.me.uk/openbsd-desktop-dotfiles/tree/.local/bin/screenshot.sh + +dir="$HOME/Pictures/Screenshots" +mkdir -p "$dir" +img_path="$dir/$(date +%Y-%m-%d_%H-%M-%S).png" + +copy_to_clipboard() { + xclip -selection clipboard -t image/png -i "$1" +} + +current_screen() { + set -- $(xrandr --current | awk '/ connected/ {print $3}' | grep '^[0-9]') + geom="$1" + + MONW=$(echo "$geom" | awk -F '[x+]' '{print $1}') + MONH=$(echo "$geom" | awk -F '[x+]' '{print $2}') + MONX=$(echo "$geom" | awk -F '[x+]' '{print $3}') + MONY=$(echo "$geom" | awk -F '[x+]' '{print $4}') +} + +take_action() { + case "$1" in + "screen") + current_screen + maim -g "${MONW}x${MONH}+${MONX}+${MONY}" "$img_path" + copy_to_clipboard "$img_path" + printf '%s\n' "$img_path" + ;; + "region") + maim -s "$img_path" + copy_to_clipboard "$img_path" + printf '%s\n' "$img_path" + ;; + "window") + maim -i "$(xdotool getactivewindow)" "$img_path" + copy_to_clipboard "$img_path" + printf '%s\n' "$img_path" + ;; + "clipboard") + current_screen + maim -g "${MONW}x${MONH}+${MONX}+${MONY}" | \ + xclip -selection clipboard -t image/png + printf 'Copied screenshot to clipboard\n' + ;; + *) + exit 1 + ;; + esac +} + +if [ -n "$1" ]; then + take_action "$1" + exit 0 +fi + +choice=$(printf '%s\n' \ + "screen" \ + "region" \ + "window" \ + "clipboard" | + rofi -dmenu -i -p "screenshot") + +[ -n "$choice" ] || exit 0 +take_action "$choice" blob - /dev/null blob + 46d0ae3991b1dc8d802dec166e71269c2495b716 (mode 644) --- /dev/null +++ local/.local/bin/tailscaled @@ -0,0 +1,37 @@ +#!/bin/ksh +# +# $OpenBSD: tailscaled,v 0.1 $ + +daemon="/usr/local/sbin/tailscaled --state=/var/db/tailscale/tailscaled.state --socket=/var/run/tailscale/tailscaled.sock" +daemon_flags="--port 0 --tun tun0" + +rc_bg="YES" +rc_reload="NO" + +. /etc/rc.d/rc.subr + +# these have to be placed below the above rc.subr sourcing so that they override +# default value is: pexp="${daemon}${daemon_flags:+ ${daemon_flags}}" +pexp="tailscaled" + +rc_start() { + # default value is: ${rcexec} "${daemon} ${daemon_flags} ${_bg}" + # ${_bg} gets replaced with '&' if rc_bg=YES + + ${rcexec} "${daemon} ${daemon_flags} 2>&1 | logger -t tailscaled ${_bg}" +} + +rc_stop() { + # default value is: pkill -xf "${pexp}" + + ${rcexec} "${daemon} --cleanup ${daemon_args} 2>&1 | logger -t tailscaled" + pkill -xf "${pexp}" +} + +rc_check() { + # default value is: pgrep -q -xf "${pexp}" + + pgrep -q -x ${pexp} +} + +rc_cmd $1 blob - /dev/null blob + 8351ad08b366f1328146e4fc7f6aae247c5326e1 (mode 755) --- /dev/null +++ local/.local/bin/termbar @@ -0,0 +1,129 @@ +#!/bin/ksh +# +# Some kind of status bar for XTerm +# ./termbar +# xterm -e "./termbar" & + +PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin" + +# Restart it-self if it get a SIGHUP +trap 'echo ""; exec $0' HUP + +# Reset the terminal on exit +trap 'tput cnorm; exit 1' INT QUIT TERM + +# Get the number of columns +_cols=$(tput columns) + +# Use the terminal colors +_rset="\033[0m" # Reset / Normal formatting +_hide="\033[2m" # Decrease intensity +_hlty="\033[32m" # Green foreground +_alrt="\033[31m" # Red foreground +_warn="\033[33m" # Yellow foreground +_actv="\033[34m" # Blue foreground +_none="\033[35m" # Magenta foreground +_norm="\033[39m" # Magenta foreground + +# (Nerd Fonts) icons and colors used in functions +set -A _bat "${_norm}" "${_warn}" "${_alrt}" +set -A _snl "${_norm}" "${_warn}" "${_alrt}" "${_none}" +set -A _pwr "${_actv}" +set -A _net "eth" "wlan" +set -A _nic "em0" "urtwn0" +set -A _vol "q" "w" ":" + +# Functions that gather and print things +function bat { + (( $(apm -a) == 1 )) && _status=${_pwr[0]} \ + || _status=${_bat[$(apm -b)]} + echo -n "bat: ${_status}$(apm -l)%${_norm}" +} + +function cal { + [[ $(date "+%H") -ge 6 && $(date "+%H") -le 22 ]] \ + && echo -n "${_norm}" \ + || echo -n "${_warn}" + echo -n $(date '+%a. %Y/%m/%d %H:%M')${_norm} +} + +function cpu { + echo -n "cpu: $(sysctl -n hw.sensors.cpu0.temp0 | cut -d '.' -f 1)°C" +} + +function kbd { + #echo -n " $(setxkbmap -query | awk '/^layout:/ { print $2 }')" + setxkbmap -query | awk '/^layout:/ { printf "%s %s", "x", $2 }' +} + +function net { + [[ -z "$(ifconfig ${_nic[0]} | grep 'status: no carrier')" ]] \ + && (echo -n ${_net[0]} ; return) + _signal=$( ifconfig ${_nic[1]} | awk '/ieee80211:/ { sub(/dBm/, "", $8); print $8 }') + # Decide index: 0 = norm, 1 = warm, 2 = alert + if [[ -z $_signal ]]; then + idx=3 + _signal="󰲜 " + elif (( _signal >= -65 )); then + idx=0 + elif (( _signal >= -75 )); then + idx=1 + else + idx=2 + fi + echo "net: ${_snl[$idx]}${_signal}${_norm}" +} + +function vol { + _v=$(sndioctl -n output.level | awk '{ print int($0*100) '}) + [[ $(sndioctl -n input.mute) -eq 1 ]] \ + && echo -n "${_norm}M${_norm}" \ + || echo -n "${_warn}${_norm}" + [[ $(sndioctl -n output.mute) -eq 1 ]] \ + && echo -n "" \ + || echo -n "${_vol[$(($_v*3/101))]}" + echo -n "$_v%" +} + +function win { + _grp=$(xprop -root 32c '\t$0' _NET_CURRENT_DESKTOP | cut -f 2) + _wid=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) + [[ "$_wid" == "0x0" ]] && _win="" || \ + _win=$(xprop -id $_wid '\t$0' _NET_WM_NAME | awk -F '"' '{ print $2 }') + printf "${_hide}[ $_grp ]${_rset} %s" "${_win}" +} + +tput civis # Hide cursor + +#((_middle=$_cols/2 )) +_col_data=260 +_col_time=296 +_connected_displays=$(xrandr --query | grep " connected" | wc -l) +if [[ $_connected_displays -eq 1 ]]; then + _col_data=105 + _col_time=137 +fi + +while true; do +# tput cup 0 100 + tput cup 0 $_col_data + printf "%-40.98s" "$(cpu) $(bat) $(vol) $(net)" + + #_r=$(cal) + #((_pos=$_cols - ${#_r})) + # tput cup 0 265 + tput cup 0 $_col_time + printf "%20.100s" "$(cal)" + + for i in $(jot 15 1); do + tput cup 0 0 + printf "%-100.100s" "$(win)" + sleep .3 + done + +done + +tput cnorm # Show cursor + +#EOF + blob - /dev/null blob + 4ca9eebff9d22b63195d64d5d42615a07d76f65f (mode 644) Binary files /dev/null and local/.local/media/bsd-openbsd-wallpaper.jpg differ