5 Commits

57 changed files with 84 additions and 416 deletions

View File

@@ -1,19 +0,0 @@
# Arch Linux Notes
## Web App (PWA)
For the `webapp-install` script to work there needs to be a directory
for the icons to be installed to. It can be done with the following command:
```bash
mkdir -p ~/.local/share/applications/icons
```
## Monitor Lid Events
In order to monitor lid events, the user needs to be
added to the `input` group.
```bash
sudo usermod -aG input $USER
```

60
dev-env
View File

@@ -31,11 +31,13 @@ log() {
log "env: $DEV_ENV"
update_files() {
# Removes a destination directory and copies all files to the destination.
update_dirs() {
log "copying over files from: $1"
pushd $1 &>/dev/null
(
configs=$(find . -mindepth 1 -maxdepth 1 -type d)
# Copy everything except systemd and zsh folders, they need treated differently.
configs=$(find . -mindepth 1 -maxdepth 1 -type d \( -name "systemd" -o -name "zsh" \) -prune -o -type d -print)
for c in $configs; do
directory=${2%/}/${c#./}
log " removing: rm -rf $directory"
@@ -54,10 +56,11 @@ update_files() {
popd &>/dev/null
}
# Removes a destination file and copies a single file to the destination.
copy() {
log "removing: $2"
if [[ $dry_run == "0" ]]; then
rm $2
rm $2 &>/dev/null
fi
log "copying: $1 to $2"
if [[ $dry_run == "0" ]]; then
@@ -65,16 +68,53 @@ copy() {
fi
}
update_files $DEV_ENV/env/.config $XDG_CONFIG_HOME
update_files $DEV_ENV/env/.local $HOME/.local
#
# copy $DEV_ENV/tmux-sessionizer/tmux-sessionizer $HOME/.local/scripts/tmux-sessionizer
# Copy all files from a directory into another directory.
copy_files() {
log "copying over files from: $1"
pushd $1 &>/dev/null
(
for f in $(find . -mindepth 1 -maxdepth 1 -type f); do
local dest="$2/$(basename $f)"
if [[ $dry_run == "0" ]]; then
rm -rf $dest >/dev/null 2>&1
fi
log " copying env: cp $f $dest"
if [[ $dry_run == "0" ]]; then
cp $f $dest
fi
done
)
popd &>/dev/null
}
############################## MAIN ##############################
update_dirs $DEV_ENV/env/.config $XDG_CONFIG_HOME
update_dirs $DEV_ENV/env/.local $HOME/.local
# SYSTEMD
mkdir -p $XDG_CONFIG_HOME/systemd/user
copy_files $DEV_ENV/env/.config/systemd/user $XDG_CONFIG_HOME/systemd/user
# ZSH
# NOTE: This keeps from clobbering zsh history and plugins vs. wiping the entire directory and
# copying configuration.
copy $DEV_ENV/env/.zshenv $HOME/.zshenv
mkdir -p $XDG_CONFIG_HOME/zsh
update_dirs $DEV_ENV/env/.config/zsh $XDG_CONFIG_HOME/zsh
copy_files $DEV_ENV/env/.config/zsh $XDG_CONFIG_HOME/zsh
# TMUX
copy $DEV_ENV/env/.tmux.conf $HOME/.tmux.conf
# GPG
mkdir $HOME/.gnupg
rm $HOME/.gnupg/gpg.conf >/dev/null 1>&2 && copy $DEV_ENV/env/.gnupg/gpg.conf $HOME/.gnupg/gpg.conf
rm $HOME/.gnupg/gpg-agent.conf >/dev/null 1>&2 && copy $DEV_ENV/env/.gnupg/gpg-agent.conf $HOME/.gnupg/gpg-agent.conf
rm $HOME/.gnupg/scdaemon.conf >/dev/null 1>&2 && copy $DEV_ENV/env/.gnupg/scdaemon.conf $HOME/.gnupg/scdaemon.conf
copy_files $DEV_ENV/env/.gnupg $HOME/.gnupg
copy $DEV_ENV/dev-env $HOME/.local/scripts/dev-env
systemctl --user daemon-reload
hyprctl reload

View File

@@ -19,7 +19,7 @@ $fileManager = $terminal -e yazi
$fileBrowser = nautilus
$menu = walker
#$pwa = chromium --profile-directory=Default --enable-features=UseOzonePlatform --ozone-platform=wayland
$pwa = ~/.local/bin/launch-webapp
$pwa = ~/.local/scripts/launch-webapp
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more

View File

@@ -15,13 +15,15 @@ return {
desc = "Open the entry in a vertical split",
},
view_options = {
show_hidden = true,
is_hidden_file = function(name, _) -- second arg is bufnr, but not currently used.
-- Don't show .DS_Store in output.
local is_ds_store = name ~= ".DS_Store"
return not is_ds_store
-- local is_ds_store = name ~= ".DS_Store"
-- return not is_ds_store
return false
end,
},
}
},
},
keys = {
-- Show the parent directory in current window.
@@ -29,8 +31,10 @@ return {
-- Open parent directory in floating window.
{
"<space>-",
function() require("oil").toggle_float() end,
desc = "Open parent directory in floating window."
function()
require("oil").toggle_float()
end,
desc = "Open parent directory in floating window.",
},
},
}

View File

@@ -4,5 +4,5 @@ After=graphical-session.target
[Service]
Type=oneshot
ExecStart=%h/.local/bin/battery-monitor
ExecStart=%h/.local/scripts/battery-monitor
Environment=DISPLAY=:0

View File

@@ -5,7 +5,7 @@ Before=exit.target
[Service]
Type=oneshot
ExecStart=%h/.local/bin/clear-clipboard-history
ExecStart=%h/.local/scripts/clear-clipboard-history
[Install]
WantedBy=exit.target

View File

@@ -100,6 +100,9 @@ MIME_TYPES=$mime_types[-1]
# Refer to local icon or fetch remotely from URL
ICON_DIR="$HOME/.local/share/applications/icons"
# Ensure the icon directory exists (useful if it's the first run.)
[ ! -d $ICON_DIR ] && mkdir -p $ICON_DIR
if [[ $ICON_REF == https://* ]]; then
ICON_PATH="$ICON_DIR/$APP_NAME.png"
if curl -sL -o "$ICON_PATH" "$ICON_REF"; then
@@ -121,7 +124,7 @@ fi
if [[ -n $CUSTOM_EXEC ]]; then
EXEC_COMMAND="$CUSTOM_EXEC"
else
EXEC_COMMAND="$HOME/.local/bin/launch-webapp $APP_URL"
EXEC_COMMAND="${SCRIPTS:-$HOME/.local/scripts}/launch-webapp $APP_URL"
fi
# Create application .desktop file

28
env/.zshenv vendored
View File

@@ -27,31 +27,14 @@ export GITUSER="m-housh"
export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
# Directories
export ARCHIVE="/Volumes/Archive"
export BUCKET="/Volumes/Bucket"
export REPOS="/Volumes/Bucket/Repos"
export DRIVE="/Volumes/Personal-Drive"
export ANSIBLE_LOCAL="$REPOS/ansible"
export ANSIBLE_GEN_DIR="$ANSIBLE_LOCAL/ansible-gen-playbook"
export ANSIBLE_MACOS_PLAYBOOK_DIR="$HOME/ansible-macos-playbook"
export CONSULTS="$DRIVE/Consults"
export DOTFILES="$HOME/.dotfiles"
export DEV_ENV="$HOME/.dotfiles"
export DOCUMENTS="$HOME/Documents"
export DOWNLOADS="$HOME/Downloads"
export GHREPOS="$REPOS/github.com"
export LOCAL_REPOS="$REPOS/local"
export LOCAL_ENV="$XDG_DATA_HOME/zsh/env.zsh"
export MYZSHRC="$ZDOTDIR/.zshrc"
export NAP_CONFIG="$HOME/.config/nap/config.yaml"
export PDFS="$HOME/Library/Mobile Documents/com~apple~Preview/Documents"
export PROPOSALS="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work/Proposals"
export SCREENSHOTS="$BUCKET/Pictures/Screenshots"
export SCRIPTS="$XDG_DATA_HOME/scripts"
export SITES="$GHREPOS/sites"
export SCRIPTS="$HOME/.local/scripts"
export SKELETONDIR="$DOTFILES/skeleton"
export WORK="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work"
export ZETDIR="$GHREPOS/zets"
# NPM
export NPM_CONFIG_CACHE="$XDG_DATA_HOME/npm"
@@ -80,16 +63,11 @@ export PSQL_HISTORY="$XDG_DATA_HOME/psql_history"
# Hashicorp/Vault
export VAULT_ADDR="https://vault.housh.dev"
# Ansible
export ANSIBLE_HOME="$XDG_CONFIG_HOME/ansible"
export ANSIBLE_VAULT_PASSWORD_FILE="$SCRIPTS/vault-gopass-client"
export DEFAULT_VAULT_PASSWORD_FILE="$SCRIPTS/vault-gopass-client"
# Rust
export CARGO_HOME="$XDG_DATA_HOME/cargo"
# Tmux-Sessionator path.
export TMUX_SESSIONATOR_PATH="$HOME:$SCRIPTS:$LOCAL_REPOS:$REPOS:$ANSIBLE_LOCAL:$GHREPOS:$HVACIOTREPOS"
export TMUX_SESSIONATOR_PATH="$HOME:$SCRIPTS"
# Password-store
export PASSWORD_STORE_DIR="$XDG_DATA_HOME/gopass/stores/root"

View File

@@ -8,35 +8,21 @@ if ! command -v yay >/dev/null 2>&1; then
rm -rf ~/yay
fi
# Basics
# Packages
yay -S --noconfirm --needed \
asahi-desktop-meta \
bat \
bc \
catppuccin-gtk-theme-mocha \
sddm-theme-catppuccin \
eza \
fastfetch \
fzf \
git-lfs \
gum \
hyprpaper \
hyrpidle \
hyprlock \
jq \
neovim \
nodejs \
npm \
nwg-look \
pam-u2f \
pcsc-tools \
starship \
swaync \
tldr \
tmux \
tree-sitter-cli \
wl-clipboard \
yubikey-manger \
zoxide \
zsh

4
runs/hyprland Executable file
View File

@@ -0,0 +1,4 @@
#!/usr/bin/env bash
yay ${1:-"-S --noconfirm"} hyprland hyprpaper hyrpidle hyprlock \
bc # used for some scripts.

10
runs/system Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
yay ${1:-"-S --noconfirm"} catppuccin-gtk-theme-mocha \
sddm-theme-catppuccin \
nwg-look \
wl-clipboard \
pam-u2f \
pcsc-tools \
swaync \
yubikey-manger

View File

@@ -1,20 +0,0 @@
#!/bin/bash
INTERNAL="eDP-1" # check with `hyprctl monitors`
# Check lid event handler with:
#
# grep -A5 -i lid /proc/bus/input/devices
#
# The event is contained in the H: Handlers=kbd event<N>
#
DEVICE="/dev/input/event0" # replace with your lid event device
evtest --grab "$DEVICE" |
while read -r line; do
if echo "$line" | grep -q "SW_LID.*value 1"; then
hyprctl keyword monitor "$INTERNAL,disable"
elif echo "$line" | grep -q "SW_LID.*value 0"; then
hyprctl keyword monitor "$INTERNAL,preferred,auto,auto"
fi
done

View File

@@ -1,75 +0,0 @@
#!/bin/bash
function copy() {
local item=$1
local dest=${2:-~/.config}
if [ -d "$item" ]; then
cp -Rfv "$item" "$dest"
else
cp -fv "$item" "$dest"
fi
}
gpgs=(
"gpg/gpg.conf"
"gpg/gpg-agent.conf"
"gpg/scdaemon.conf"
)
ln -sfv ~/.dotfiles/clipse ~/.config
ln -sfv ~/.dotfiles/eza ~/.config
ln -sfv ~/.dotfiles/ghostty ~/.config
ln -sfv ~/.dotfiles/git ~/.config
# TODO: Remove kitty.
ln -sfv ~/.dotfiles/kitty ~/.config
ln -sfv ~/.dotfiles/npm ~/.config
ln -sfv ~/.dotfiles/nvim/lazynvim ~/.config
ln -sfv ~/.dotfiles/starship ~/.config
ln -sfv ~/.dotfiles/systemd ~/.config
ln -sfv ~/.dotfiles/tree-sitter ~/.config
ln -sfv ~/.dotfiles/walker ~/.config
ln -sfv ~/.dotfiles/waybar ~/.config
ln -sfv ~/.dotfiles/yubico ~/.config
# Espanso
espanso service stop
rm -rf ~/.config/espanso >/dev/null 2>&1
ln -sfV ~/.dotfiles/espanso ~/.config
espanso service start
# Hyprland
rm -rf ~/.config/hypr >/dev/null 2>&1
ln -sfv ~/.dotfiles/hypr ~/.config
# GPG
mkdir ~/.gnupg
chmod 700 ~/.gnupg
ln -sfv ~/.dotfiles/gpg/gpg-agent.conf ~/.gnupg/gpg-agent.conf
ln -sfv ~/.dotfiles/gpg/gpg.conf ~/.gnupg/gpg.conf
ln -sfv ~/.dotfiles/gpg/scdaemon.conf ~/.gnupg/scdaemon.conf
# yazi
mkdir ~/.config/yazi
ln -sfv ~/.dotfiles/yazi/theme.toml ~/.config/yazi/theme.toml
ln -sfv ~/.dotfiles/yazi/yazi.toml ~/.config/yazi/yazi.toml
# tmux
mkdir -p ~/.config/tmux/plugins
ln -sfv ~/.dotfiles/tmux/tmux.conf ~/.config/tmux/tmux.conf
# scripts
mkdir -p ~/.local/share
ln -sfv ~/.dotfiles/scripts/arch ~/.local/bin
ln -sfv ~/.dotfiles/scripts/scripts ~/.local/share/scripts
# zsh
mkdir -p ~/.config/zsh/plugins
ln -sfv ~/.dotfiles/zsh/.zshenv ~/.zshenv
ln -sfv ~/.dotfiles/zsh/config/.zshenv ~/.config/zsh/.zshenv
ln -sfv ~/.dotfiles/zsh/config/.zshrc ~/.config/zsh/.zshrc
ln -sfv ~/.dotfiles/zsh/config/functions ~/.config/zsh/functions
ln -sfv ~/.dotfiles/zsh/config/zsh-functions ~/.config/zsh/zsh-functions
touch ~/.config/zsh/history
chmod 600 ~/.config/zsh/history
chsh -s $(which zsh)

View File

@@ -1,12 +0,0 @@
#!/bin/sh
set -e
font_dir="$(brew --prefix)/share/figlet/fonts"
for font in "${font_dir}"/*.flf; do
clear
echo "FONT: $font"
figlet -f "${font}" hello
read -r line
done

View File

@@ -1,8 +0,0 @@
#!/bin/sh
set -e
message="${1:-m-housh}"
font="${2:-puffy}"
echo "${message}" | figlet -c -f "${font}"

View File

@@ -1,9 +0,0 @@
#!/bin/sh
if [ "$(uname -n)" = "Michaels-Mac-mini.local" ]; then
echo "Removing derived data folders"
rm -r /Volumes/Bucket/Library/Developer/Xcode/DerivedData
else
echo "Removing derived data folders"
rm -r ~/Library/Developer/Xcode/DerivedData/*
fi

View File

@@ -1,8 +0,0 @@
#!/bin/zsh
# adapted from...
# https://github.com/rwxrob/dot/blob/main/scripts/cmt
while IFS= read -r line; do
echo "${1:-#} $line"
done

View File

@@ -1,5 +0,0 @@
#!/bin/bash
url="https://lite.duckduckgo.com/lite?kd=1&kp=1&q=$(urlencode "$*")"
exec lynx -vikeys "$url"

View File

@@ -1,16 +0,0 @@
#!/bin/bash
# Create a new figlet (ascii art) from the input.
figl() {
font=${FIGL_FONT:-puffy}
declare -a buf
while IFS= read -r line; do
buf+=("$line")
done
for line in "${buf[@]}"; do
figlet -f "$font" -c "${line}" | head -6
done
}
figl "$*"

View File

@@ -1,58 +0,0 @@
#!/bin/sh
# Creates symlinks from external application directory
# to another directory so applications are seen in
# spotlight searches and launchpad.
set -e
app_dir=""
destination_dir=""
# Parses the input arguments. If 2 arguments are passed in, then
# the first is where we search for applications (source) and the second
# argument is the destination directory for the symlinks to be placed in
#
# If one argument is passed in, then it is used as the destination directory
# and we use the default source directory.
_parse_args() {
arg_count="$#"
app_dir="/Volumes/M1 Mac-Mini External Drive/Applications"
destination_dir="${HOME}/Application"
if test "$arg_count" -eq 1; then
destination_dir="$1"
elif test "$arg_count" -eq 2; then
app_dir="$1"
destination_dir="$2"
fi
}
# Checks if the `app_dir` exists.
_is_mounted() {
if ! test -d "$app_dir"; then
echo "Application directory does not exist or is not mounted" >&2
return 1
fi
}
# ---------------- main -------------------
main() {
_parse_args "$@"
test -d "${destination_dir}" || echo "Destination does not exist" >&2
if test _is_mounted; then
for app in "${app_dir}"/*.app; do
destination="${destination_dir}/$(basename "${app}")"
if test -e "${destination}"; then
echo "Destination already exists: ${destination}. Skipping!" >&2
continue
fi
# remove echo to do real work.
echo ln -sv "${app}" "${destination}" >&2
done
fi
}
main "$@"

View File

@@ -1,94 +0,0 @@
#!/usr/bin/env zsh
# Posts to facebook group and personal page.
#
# Typical usage would be to generate a link to the latest
# blog post and send to facebook:
#
# `$ mhlink --last | xargs -I {} post-to-facebook -m <optional-message> {}`
#
#
#################### Options ####################
declare -a message
zparseopts -D -F -K -- \
{a,-all}=locationOpt \
{m,-message}+:=message \
{o,-offline}=offline \
{p,-personal}=locationOpt \
{h,-help}=help
baseUrl="https://graph.facebook.com/v18.0"
link=$1
message="${message[-1]}"
token=$(cat < "$HOME/.config/facebook-bot/access-token.txt")
#################### Usage ####################
function usage() {
cat <<EOF
post-to-facebook: Create posts on facebook using. This accepts
a link as an argument and a message option. Either the message
or the link (or both) needs to be supplied.
Typical usage:
post-to-facebook --message "Some message" "https://mhouhs.com/<post>"
Usage: post-to-facebook [-a] [-m <message>] [-o] [-p] <link>
-a | --all: Send the post to the group and personal pages.
-m | --message: The optional message.
-o | --offline: Do not send the request(s), but print them.
-p | --personal: Send to personal page only.
-h | --help: Show the usage.
The -a or -p options are optional, if neither is supplied then it will
only be posted to the group.
EOF
}
#################### Helpers ####################
function post() {
local url=$1
if [ -n "$offline" ]; then
echo "Offline mode, request not being sent."
http --offline --ignore-stdin POST "$url" access_token=="$token" \
link="$link" \
message="$message"
else
http --ignore-stdin POST "$url" access_token=="$token" \
link="$link" \
message="$message"
fi
}
function post_to_group() {
group=$(cat < "$HOME/.config/facebook-bot/group.txt")
post "$baseUrl/$group/feed"
}
function post_to_personal() {
post "$baseUrl/me/feed"
}
#################### Main ####################
[ -n "$help" ] && usage && exit 0
[ -z "$link" ] && [ -z "$message" ] \
&& echo "Link or message is required." \
&& exit 1
[ "$locationOpt" = "-p" ] || [ "$locationOpt" = "--personal" ] \
&& post_to_personal \
&& exit 0
[ "$locationOpt" = "-a" ] || [ "$locationOpt" = "--all" ] \
&& post_to_personal
post_to_group

View File

@@ -1,8 +0,0 @@
#!/bin/bash
# adapted from...
# https://github.com/rwxrob/dot/blob/main/scripts/ucmt
while IFS= read -r line; do
echo "${line#* }"
done

View File

@@ -1 +0,0 @@
/home/michael/.config/systemd/user/espanso.service

View File

@@ -1,11 +0,0 @@
[Unit]
Description=espanso
[Service]
ExecStart=/usr/bin/espanso launcher
Restart=on-failure
RestartSec=3
[Install]
WantedBy=default.target

View File

@@ -1 +0,0 @@
/usr/lib/systemd/user/hypridle.service

View File

@@ -1 +0,0 @@
/usr/lib/systemd/user/hyprpaper.service

View File

@@ -1,11 +0,0 @@
[Unit]
Description=Hyprland lid handler using evdev
After=graphical.target
[Service]
ExecStart=%h/.local/bin/lid.sh
Restart=always
[Install]
WantedBy=default.target