mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 22:22:40 +00:00
feat: Rearranges scripts directory, fixes zsh configuration clobbering history and plugins.
This commit is contained in:
17
dev-env
17
dev-env
@@ -36,8 +36,8 @@ update_files() {
|
|||||||
log "copying over files from: $1"
|
log "copying over files from: $1"
|
||||||
pushd $1 &>/dev/null
|
pushd $1 &>/dev/null
|
||||||
(
|
(
|
||||||
# Copy everything except systemd folder, it needs treated differently.
|
# Copy everything except systemd and zsh folders, they need treated differently.
|
||||||
configs=$(find . -mindepth 1 -maxdepth 1 -name "systemd" -prune -o -type d -print)
|
configs=$(find . -mindepth 1 -maxdepth 1 -type d \( -name "systemd" -o -name "zsh" \) -prune -o -type d -print)
|
||||||
for c in $configs; do
|
for c in $configs; do
|
||||||
directory=${2%/}/${c#./}
|
directory=${2%/}/${c#./}
|
||||||
log " removing: rm -rf $directory"
|
log " removing: rm -rf $directory"
|
||||||
@@ -75,15 +75,24 @@ copy_files() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
############################## MAIN ##############################
|
||||||
|
|
||||||
update_files $DEV_ENV/env/.config $XDG_CONFIG_HOME
|
update_files $DEV_ENV/env/.config $XDG_CONFIG_HOME
|
||||||
update_files $DEV_ENV/env/.local $HOME/.local
|
update_files $DEV_ENV/env/.local $HOME/.local
|
||||||
|
|
||||||
# Systemd.
|
# SYSTEMD
|
||||||
mkdir -p $XDG_CONFIG_HOME/systemd/user
|
mkdir -p $XDG_CONFIG_HOME/systemd/user
|
||||||
copy_files $DEV_ENV/env/.config/systemd/user $XDG_CONFIG_HOME/systemd/user
|
copy_files $DEV_ENV/env/.config/systemd/user $XDG_CONFIG_HOME/systemd/user
|
||||||
|
|
||||||
# copy $DEV_ENV/tmux-sessionizer/tmux-sessionizer $HOME/.local/scripts/tmux-sessionizer
|
# 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
|
copy $DEV_ENV/env/.zshenv $HOME/.zshenv
|
||||||
|
mkdir -p $XDG_CONFIG_HOME/zsh
|
||||||
|
update_files $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
|
copy $DEV_ENV/env/.tmux.conf $HOME/.tmux.conf
|
||||||
|
|
||||||
# GPG
|
# GPG
|
||||||
|
|||||||
2
env/.config/hypr/keybinds.conf
vendored
2
env/.config/hypr/keybinds.conf
vendored
@@ -19,7 +19,7 @@ $fileManager = $terminal -e yazi
|
|||||||
$fileBrowser = nautilus
|
$fileBrowser = nautilus
|
||||||
$menu = walker
|
$menu = walker
|
||||||
#$pwa = chromium --profile-directory=Default --enable-features=UseOzonePlatform --ozone-platform=wayland
|
#$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
|
# Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more
|
||||||
|
|
||||||
|
|||||||
2
env/.local/scripts/install-webapp
vendored
2
env/.local/scripts/install-webapp
vendored
@@ -121,7 +121,7 @@ fi
|
|||||||
if [[ -n $CUSTOM_EXEC ]]; then
|
if [[ -n $CUSTOM_EXEC ]]; then
|
||||||
EXEC_COMMAND="$CUSTOM_EXEC"
|
EXEC_COMMAND="$CUSTOM_EXEC"
|
||||||
else
|
else
|
||||||
EXEC_COMMAND="$HOME/.local/bin/launch-webapp $APP_URL"
|
EXEC_COMMAND="$HOME/.local/scripts/launch-webapp $APP_URL"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create application .desktop file
|
# Create application .desktop file
|
||||||
|
|||||||
2
env/.zshenv
vendored
2
env/.zshenv
vendored
@@ -47,7 +47,7 @@ export NAP_CONFIG="$HOME/.config/nap/config.yaml"
|
|||||||
export PDFS="$HOME/Library/Mobile Documents/com~apple~Preview/Documents"
|
export PDFS="$HOME/Library/Mobile Documents/com~apple~Preview/Documents"
|
||||||
export PROPOSALS="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work/Proposals"
|
export PROPOSALS="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work/Proposals"
|
||||||
export SCREENSHOTS="$BUCKET/Pictures/Screenshots"
|
export SCREENSHOTS="$BUCKET/Pictures/Screenshots"
|
||||||
export SCRIPTS="$$HOME/.local/scripts"
|
export SCRIPTS="$HOME/.local/scripts"
|
||||||
export SITES="$GHREPOS/sites"
|
export SITES="$GHREPOS/sites"
|
||||||
export SKELETONDIR="$DOTFILES/skeleton"
|
export SKELETONDIR="$DOTFILES/skeleton"
|
||||||
export WORK="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work"
|
export WORK="$HOME/Library/Mobile Documents/com~apple~CloudDocs/Work"
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
# Used with the systemd battery monitor service and timer to alert
|
|
||||||
# when the battery has dropped below the threshold and is not currently
|
|
||||||
# charging.
|
|
||||||
|
|
||||||
THRESHOLD=20 # Notify when below 20%
|
|
||||||
NOTIFICATION_FLAG="/run/user/${UID}/user_battery_notified"
|
|
||||||
|
|
||||||
function get-battery-percentage() {
|
|
||||||
local battery=$(upower --battery | grep percentage)
|
|
||||||
echo "${battery//[^0-9]/}"
|
|
||||||
}
|
|
||||||
|
|
||||||
function send-battery-alert() {
|
|
||||||
notify-send -u critical \
|
|
||||||
"Recharge battery!" "Batttery is down to ${1}" \
|
|
||||||
-i battery-caution \
|
|
||||||
-t 30000
|
|
||||||
}
|
|
||||||
|
|
||||||
battery_percentage=$(get-battery-percentage)
|
|
||||||
battery_state=$(upower --battery | grep -E state | awk '{print $2}')
|
|
||||||
|
|
||||||
if [[ "$battery_state" == "discharging" && "$battery_percentage" -le "$THRESHOLD" ]]; then
|
|
||||||
if [ ! -f "$NOTIFICATION_FLAG" ]; then
|
|
||||||
send-battery-alert "$battery_percentage"
|
|
||||||
touch "$NOTIFICATION_FLAG"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
rm -f "$NOTIFICATION_FLAG"
|
|
||||||
fi
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#wl-copy --clear >/dev/null 2>&1 && \
|
|
||||||
if [ -n "$WAYLAND_DISPLAY" ]; then
|
|
||||||
wl-copy --clear
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm ~/.local/share/clipse/clipboard_history.json >/dev/null 2>&1
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
hyprctl clients -j | \
|
|
||||||
jq '.[] | .address' | \
|
|
||||||
xargs -I{} hyprctl dispatch closewindow address:{}
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file
|
|
||||||
|
|
||||||
function usage() {
|
|
||||||
cat <<EOF
|
|
||||||
Generates a '.desktop' file for a web application, so that it
|
|
||||||
can act as a stand alone application and launched from an application
|
|
||||||
launcher.
|
|
||||||
|
|
||||||
USAGE: install-webapp [-n <name>] [-u <url>] [-i <icon>] [-e <exec-cmd>] [-m <mime-types>] [-h] [args...]
|
|
||||||
|
|
||||||
OPTIONS:
|
|
||||||
-n | --name: The name of the application.
|
|
||||||
-u | --url: The url used to launch the application.
|
|
||||||
-i | --icon: The icon for the application.
|
|
||||||
-e | --exec: Custom execution command (optional).
|
|
||||||
-m | --mime-types: MIME-types for the application (optional).
|
|
||||||
-h | --help: Show usage information.
|
|
||||||
|
|
||||||
EXAMPLES:
|
|
||||||
|
|
||||||
If no options or arguments are supplied, then it will start an interactive session that prompts for the
|
|
||||||
values.
|
|
||||||
|
|
||||||
$ install-webapp
|
|
||||||
|
|
||||||
Calling the app with named arguments:
|
|
||||||
|
|
||||||
$ install-webapp \\
|
|
||||||
--name "My Awesome App" \\
|
|
||||||
--url "https://awesome.com" \\
|
|
||||||
--icon "https://awesome.com/assets/icon.png"
|
|
||||||
|
|
||||||
It is also possible to use only positional arguments with out their key. They can be passed in the order as
|
|
||||||
they're listed.
|
|
||||||
|
|
||||||
$ install-webapp "My Awesome App" \\
|
|
||||||
"https://awesome.com" \\
|
|
||||||
"https://awesome.com/assets/icon.png"
|
|
||||||
|
|
||||||
NOTES:
|
|
||||||
|
|
||||||
The icon option can either be a url where we will download a png from or a local file. Local files
|
|
||||||
can either be the full path to the file or a file name of an icon located in '~/.local/share/applications/icons/'.
|
|
||||||
|
|
||||||
Interactive sessions do not give the option to use a custom execution command or supply the
|
|
||||||
MIME types, which are less frequently used options.
|
|
||||||
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
declare -a app_name
|
|
||||||
declare -a app_url
|
|
||||||
declare -a icon_ref
|
|
||||||
declare -a custom_exec # Optional custom exec command
|
|
||||||
declare -a mime_types # Optional mime types
|
|
||||||
declare -a help_flag
|
|
||||||
declare INTERACTIVE_MODE=false
|
|
||||||
|
|
||||||
zparseopts -D -F -K -- \
|
|
||||||
{n,-name}:=app_name \
|
|
||||||
{u,-url}:=app_url \
|
|
||||||
{i,-icon}:=icon_ref \
|
|
||||||
{e,-exec}:=custom_exec \
|
|
||||||
{m,-mime-types}:=mime_types \
|
|
||||||
{h,-help}=help_flag
|
|
||||||
|
|
||||||
[ ${#help_flag[@]} -gt 0 ] && usage && exit 0
|
|
||||||
|
|
||||||
# If passed in as positional arguments, without flags.
|
|
||||||
[ -n "$1" ] && app_name+=("$1")
|
|
||||||
[ -n "$2" ] && app_url+=("$2")
|
|
||||||
[ -n "$3" ] && icon_ref+=("$3")
|
|
||||||
[ -n "$4" ] && custom_exec+=("$4")
|
|
||||||
[ -n "$5" ] && mime_types+=("$5")
|
|
||||||
|
|
||||||
# Check if proper arguments were passed in. Start interactive mode if not.
|
|
||||||
if [[ -z "$app_name[-1]" || -z "$app_url[-1]" || -z "$icon_ref[-1]" ]]; then
|
|
||||||
echo -e "\e[32mLet's create a new web app you can start with the app launcher.\n\e[0m"
|
|
||||||
app_name+=($(gum input --prompt "Name> " --placeholder "My favorite web app"))
|
|
||||||
app_url+=($(gum input --prompt "URL> " --placeholder "https://example.com"))
|
|
||||||
icon_ref+=($(gum input --prompt "Icon URL> " --placeholder "See https://dashboardicons.com (must use PNG!)"))
|
|
||||||
INTERACTIVE_MODE=true
|
|
||||||
else
|
|
||||||
INTERACTIVE_MODE=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Ensure valid execution
|
|
||||||
if [[ -z "$app_name[-1]" || -z "$app_url[-1]" || -z "$icon_ref[-1]" ]]; then
|
|
||||||
echo "You must set app name, app URL, and icon URL!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
APP_NAME=$app_name[-1]
|
|
||||||
APP_URL=$app_url[-1]
|
|
||||||
ICON_REF=$icon_ref[-1]
|
|
||||||
CUSTOM_EXEC=$custom_exec[-1]
|
|
||||||
MIME_TYPES=$mime_types[-1]
|
|
||||||
|
|
||||||
# Refer to local icon or fetch remotely from URL
|
|
||||||
ICON_DIR="$HOME/.local/share/applications/icons"
|
|
||||||
if [[ $ICON_REF == https://* ]]; then
|
|
||||||
ICON_PATH="$ICON_DIR/$APP_NAME.png"
|
|
||||||
if curl -sL -o "$ICON_PATH" "$ICON_REF"; then
|
|
||||||
ICON_PATH="$ICON_DIR/$APP_NAME.png"
|
|
||||||
else
|
|
||||||
echo "Error: Failed to download icon."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# Check if the icon path is a file.
|
|
||||||
if [ -f $ICON_REF ]; then
|
|
||||||
ICON_PATH=$ICON_REF
|
|
||||||
else
|
|
||||||
ICON_PATH="$ICON_DIR/$ICON_REF"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use custom exec if provided, otherwise default behavior
|
|
||||||
if [[ -n $CUSTOM_EXEC ]]; then
|
|
||||||
EXEC_COMMAND="$CUSTOM_EXEC"
|
|
||||||
else
|
|
||||||
EXEC_COMMAND="$HOME/.local/bin/launch-webapp $APP_URL"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create application .desktop file
|
|
||||||
DESKTOP_FILE="$HOME/.local/share/applications/$APP_NAME.desktop"
|
|
||||||
|
|
||||||
cat >"$DESKTOP_FILE" <<EOF
|
|
||||||
[Desktop Entry]
|
|
||||||
Version=1.0
|
|
||||||
Name=$APP_NAME
|
|
||||||
Comment=$APP_NAME
|
|
||||||
Exec=$EXEC_COMMAND
|
|
||||||
Terminal=false
|
|
||||||
Type=Application
|
|
||||||
Icon=$ICON_PATH
|
|
||||||
StartupNotify=true
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Add mime types if provided
|
|
||||||
if [[ -n $MIME_TYPES ]]; then
|
|
||||||
echo "MimeType=$MIME_TYPES" >>"$DESKTOP_FILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
chmod +x "$DESKTOP_FILE"
|
|
||||||
|
|
||||||
if [[ $INTERACTIVE_MODE == true ]]; then
|
|
||||||
echo -e "You can now find $APP_NAME using the app launcher (SUPER + SPACE)\n"
|
|
||||||
fi
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Adapted from https://github.com/basecamp/omarchy/tree/master?tab=readme-ov-file
|
|
||||||
#
|
|
||||||
browser="chromium.desktop"
|
|
||||||
|
|
||||||
exec setsid uwsm app -- $(sed -n 's/^Exec=\([^ ]*\).*/\1/p' {~/.local,~/.nix-profile,/usr}/share/applications/$browser 2>/dev/null | head -1) --app="$1" "${@:2}"
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Moves all workspaces to the passed in monitor id, which can be useful when
|
|
||||||
# connecting or disconnecting from a monitor.
|
|
||||||
|
|
||||||
MONITOR=$1
|
|
||||||
|
|
||||||
if [ ! $# = 1 ]; then
|
|
||||||
echo "Usage: mv-all-workspaces-to-monitor <monitor-id>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
hyprctl workspaces -j |
|
|
||||||
jq '.[] | select(.monitorID != "$MONITOR") | .id' |
|
|
||||||
xargs -I{} hyprctl dispatch moveworkspacetomonitor {} "$MONITOR" >/dev/null 2>&1
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Workspace to hide everything in
|
|
||||||
HIDE_WS="special:hidden"
|
|
||||||
|
|
||||||
# File to store original workspace ID
|
|
||||||
STATE_FILE="/tmp/hypr_hide_state"
|
|
||||||
|
|
||||||
# Get current workspace ID
|
|
||||||
CUR_WS=$(hyprctl -j activeworkspace | jq -r '.id')
|
|
||||||
|
|
||||||
# Check if we're currently hidden
|
|
||||||
if [[ -f "$STATE_FILE" ]]; then
|
|
||||||
# Restore windows
|
|
||||||
ORIG_WS=$(cat "$STATE_FILE")
|
|
||||||
for win in $(hyprctl -j clients | jq -r ".[] | select(.workspace.name | contains(\"$HIDE_WS\")) | .address"); do
|
|
||||||
hyprctl dispatch movetoworkspace "$ORIG_WS,address:$win"
|
|
||||||
hyprctl dispatch workspace "$ORIG_WS"
|
|
||||||
done
|
|
||||||
rm "$STATE_FILE"
|
|
||||||
else
|
|
||||||
# Hide all windows (move to special hidden workspace)
|
|
||||||
for win in $(hyprctl -j clients | jq -r ".[] | select(.workspace.id == $CUR_WS) | .address"); do
|
|
||||||
hyprctl dispatch movetoworkspace "$HIDE_WS,address:$win"
|
|
||||||
hyprctl dispatch togglespecialworkspace "$HIDE_WS"
|
|
||||||
done
|
|
||||||
rm "$STATE_FILE"
|
|
||||||
echo "$CUR_WS" >"$STATE_FILE"
|
|
||||||
fi
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
#
|
|
||||||
# Toggles the state of the internal laptop monitor, which is useful
|
|
||||||
# when I'm connected to an external monitor / docks.
|
|
||||||
|
|
||||||
monitor="eDP-1"
|
|
||||||
|
|
||||||
if hyprctl monitors | grep -q "$monitor"; then
|
|
||||||
hyprctl keyword monitor "$monitor,disable" 1>/dev/null
|
|
||||||
else
|
|
||||||
hyprctl keyword monitor "$monitor,enable" 1>/dev/null
|
|
||||||
fi
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
WAYBAR_PID=$(pgrep -x waybar)
|
|
||||||
|
|
||||||
if [ -n "$WAYBAR_PID" ]; then
|
|
||||||
# kill waybar process if it's running.
|
|
||||||
kill "$WAYBAR_PID"
|
|
||||||
else
|
|
||||||
# start waybar in the background.
|
|
||||||
waybar &
|
|
||||||
fi
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
pkill -x waybar
|
|
||||||
setsid uwsm app -- waybar >/dev/null 2>&1 &
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# Float's a window, setting it's height and width and centering.
|
|
||||||
|
|
||||||
# The percentage of the screen size for the floating window.
|
|
||||||
WIDTH_PERCENT=80
|
|
||||||
HEIGHT_PERCENT=40
|
|
||||||
|
|
||||||
floating=$(hyprctl activewindow -j | jq '.floating')
|
|
||||||
|
|
||||||
if [ "$floating" = "true" ]; then
|
|
||||||
hyprctl dispatch togglefloating
|
|
||||||
else
|
|
||||||
monitor=$(hyprctl monitors -j | jq '.[] | select(.focused == true)')
|
|
||||||
mw=$(echo "$monitor" | jq '.width')
|
|
||||||
mh=$(echo "$monitor" | jq '.height')
|
|
||||||
ms=$(echo "$monitor" | jq '.scale')
|
|
||||||
|
|
||||||
echo "scale: $ms"
|
|
||||||
|
|
||||||
neww=$(echo "scale=6; (($mw / $ms) * $WIDTH_PERCENT / 100)" | bc)
|
|
||||||
newh=$(echo "scale=6; (($mh / $ms) * $HEIGHT_PERCENT / 100)" | bc)
|
|
||||||
|
|
||||||
hyprctl dispatch togglefloating &&
|
|
||||||
hyprctl dispatch resizeactive exact $neww $newh &&
|
|
||||||
hyprctl dispatch centerwindow
|
|
||||||
fi
|
|
||||||
Reference in New Issue
Block a user