Local executables
This commit is contained in:
parent
0950890a1a
commit
e1ab9e25a5
67
.local/bin/i3-sensible-launcher
Executable file
67
.local/bin/i3-sensible-launcher
Executable file
@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
exec < /dev/null
|
||||
exec > >(systemd-cat -t i3-sensible-launcher -p info)
|
||||
exec 2> >(systemd-cat -t i3-sensible-launcher -p err)
|
||||
|
||||
pyenv shell system
|
||||
|
||||
current_workspace=$(swaymsg -t get_workspaces | jq '.[] | select(.focused==true).name' -r)
|
||||
|
||||
ws_data=$(jq < $HOME/.config/sway/workspaces.json "[.[] | values[]] | flatten(1) | .[] | select(.index==${current_workspace})" -c)
|
||||
|
||||
program=$(echo $ws_data | jq -r '.exec')
|
||||
program_name=$(echo $ws_data | jq -r '.program_name')
|
||||
memory_profile=$(echo $ws_data | jq '.memory_profile' -c)
|
||||
run_with_systemd=$(echo $ws_data | jq '.systemd' -r)
|
||||
void_output=$(echo $ws_data | jq '.void_output' -r)
|
||||
|
||||
systemd_run_args=""
|
||||
|
||||
if [[ $memory_profile != "null" ]]; then
|
||||
max_memory=$(echo $memory_profile | jq -r '.max')
|
||||
high_memory=$(echo $memory_profile | jq -r '.high')
|
||||
systemd_run_args+="--property=MemoryAccounting=yes --property=MemoryMax=${max_memory} --property=MemoryHigh=${high_memory}"
|
||||
fi
|
||||
|
||||
pty=alacritty
|
||||
|
||||
function error() {
|
||||
gxmessage -buttons "OK:0" -name "Program Launch Error" -title "Program Launch Error" "Error: This workspace is not assigned a default program" -borderless -wrap -center -sticky -default OK
|
||||
}
|
||||
|
||||
if [[ $program == "" ]]; then
|
||||
echo "error: no program for workspace ${current_workspace} is defined (got ${program})" >&2
|
||||
exec error
|
||||
fi
|
||||
|
||||
echo "Launching application $program"
|
||||
|
||||
if [[ $program == "console" ]] && [[ $pty == "alacritty" ]]; then
|
||||
# Create a new window if an instance is already running, otherwise start the service
|
||||
$pty msg create-window || /usr/bin/systemctl --user start alacritty.service
|
||||
exit 0
|
||||
elif [[ $program == "console" ]]; then
|
||||
program=$pty
|
||||
fi
|
||||
|
||||
if [[ $void_output == "true" ]]; then
|
||||
# Run it under a scope for resource control, but don't capture stdout/stderr
|
||||
# This should only be used for programs that either produce no output, or
|
||||
# produce so much output that it would flood the journal and make it
|
||||
# difficult to use.
|
||||
exec > /dev/null
|
||||
exec 2> /dev/null
|
||||
exec systemd-run --user $=systemd_run_args --scope --unit="$program_name-$$" --description="$program_name" --slice=gui.slice -- $=program
|
||||
fi
|
||||
|
||||
if [[ $run_with_systemd == "false" ]]; then
|
||||
# Run it under systemd-cat to capture stdout/stderr to journal, but don't use systemd-run
|
||||
# so that we don't get resource control
|
||||
exec systemd-cat -t $program_name -p info -- $=program
|
||||
fi
|
||||
|
||||
# Run programs using systemd-run to allow for resource control and capture of stdout/stderr
|
||||
# We're using a service instead of a scope because scopes don't capture output, and wrapping
|
||||
# the call in systemd-cat is more complicated than just using a service.
|
||||
exec systemd-run --user $=systemd_run_args --unit="$program_name-$$" --description="$program_name" --slice=gui.slice -- $=program
|
||||
26
.local/bin/i3-sensible-workspaces
Executable file
26
.local/bin/i3-sensible-workspaces
Executable file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
output_sets=("DP-1" "DP-2")
|
||||
|
||||
current_output=$(swaymsg -t get_workspaces | jq '.[] | select(.focused==true).output' | cut -d'"' -f2)
|
||||
current_workspace=$(swaymsg -t get_workspaces | jq '.[] | select(.focused==true).name' | cut -d'"' -f2)
|
||||
|
||||
function get_ws {
|
||||
ws_set=$1
|
||||
ws_target=$2
|
||||
workspace=$((ws_set * 10 + ws_target))
|
||||
|
||||
if (( workspace == current_workspace )); then
|
||||
workspace=$(( (workspace + 9) % 20 + 1 ))
|
||||
fi
|
||||
|
||||
echo $workspace
|
||||
}
|
||||
|
||||
i=0
|
||||
for output in $output_sets; do
|
||||
if [[ $current_output == $output ]]; then
|
||||
get_ws $i $1
|
||||
fi
|
||||
((i++))
|
||||
done
|
||||
44
.local/bin/screenlock
Executable file
44
.local/bin/screenlock
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
#i3lock -u -i ~/.config/i3lock/background -e -f
|
||||
|
||||
background="#1e1e1e"
|
||||
#inside="#2d272f"
|
||||
inside=$background
|
||||
blue="#7587a6"
|
||||
green="#8f9d6a"
|
||||
orange="#f9ee98"
|
||||
yellow="#f9ee98"
|
||||
red="#cf6a4c"
|
||||
purple="#815986"
|
||||
|
||||
swaylock --font 'Source Sans Pro' --font-size 15 \
|
||||
--indicator-radius 80 --indicator-thickness 10 \
|
||||
--inside-color $inside --inside-clear-color $inside --inside-caps-lock-color $inside \
|
||||
--inside-ver-color $inside --inside-wrong-color $inside \
|
||||
--key-hl-color $purple --bs-hl-color $red \
|
||||
--caps-lock-key-hl-color $orange --caps-lock-bs-hl-color $red \
|
||||
--ring-color $purple --ring-clear-color $yellow --ring-caps-lock-color $orange \
|
||||
--ring-ver-color $purple --ring-wrong-color $red -n \
|
||||
--text-color $purple --text-clear-color $yellow --text-caps-lock-color $orange \
|
||||
--text-ver-color $purple --text-wrong-color $red \
|
||||
-c $background -F -f --ignore-empty-password --indicator-idle-visible
|
||||
|
||||
sleep 1
|
||||
|
||||
#result=$(/usr/bin/node $(which aggietimed) -s /run/user/1000/aggietimed.sock --action clock-in 2>/dev/null)
|
||||
|
||||
# If the last command reported 'err' as true, or if it exited
|
||||
# non-zero, then the user did not clock in successfully. In this case,
|
||||
# we want to display a notification to the user that they did not
|
||||
# clock in successfully.
|
||||
|
||||
# if [[ $? -ne 0 ]] || [[ $result == *"err"* ]] || [[ $result == *"ERR:"* ]]; then
|
||||
# # Check to see if the user is clocked in already
|
||||
# # If they are, then don't display a notification
|
||||
# shift_data=$(/usr/bin/node $(which aggietimed) -s /run/user/1000/aggietimed.sock --action current-shift 2>/dev/null)
|
||||
|
||||
# if [[ $? -ne 0 ]] || [[ ${shift_data} == "null" ]] || [[ ${shift_data} == *"err"* ]] || [[ ${shift_data} == *"ERR:"* ]]; then
|
||||
# notify-send "Clock In Failed" "You were not successfully clocked in, please go to the website and clock in manually." -u critical -a "AggieTime"
|
||||
# fi
|
||||
# fi
|
||||
68
.local/bin/update
Executable file
68
.local/bin/update
Executable file
@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
# This script runs a full update, automatically upgrading specific packages
|
||||
# first so as to prevent the issue that occurs when the keyring package is
|
||||
# sufficiently out of date that it can't verify other packages.
|
||||
|
||||
# This script cannot be run as root, as it invokes the AUR helper `paru`.
|
||||
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
echo "This script must not be run as root" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for updates
|
||||
repo_updates=$(checkupdates --nocolor)
|
||||
aur_updates=$(paru -Qum)
|
||||
grep -q "^linux " <<< "$repo_updates"
|
||||
has_kernel_update=$?
|
||||
|
||||
# Fetch news
|
||||
news=$(paru -Pw 2> /dev/null)
|
||||
has_news=$?
|
||||
|
||||
if [[ $has_news == '0' ]]; then
|
||||
# Display news in pager if necessary (more lines than the terminal can display)
|
||||
[[ $(echo "$news" | wc -l) -gt $LINES ]] && echo "$news" | less
|
||||
[[ $(echo "$news" | wc -l) -le $LINES ]] && echo "$news"
|
||||
echo -n "Proceed with update? [y/N] "
|
||||
read -q resp
|
||||
echo
|
||||
if [[ $resp == 'n' ]]; then
|
||||
echo "Aborting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# If there is a kernel update, alert the user and prompt for confirmation
|
||||
if [[ $has_kernel_update == '0' ]]; then
|
||||
echo -n "Kernel update available. Proceed? [y/N] "
|
||||
read -q resp
|
||||
echo
|
||||
if [[ $resp == 'n' ]]; then
|
||||
echo "Aborting."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update keyring
|
||||
sudo pacman-key --populate archlinux
|
||||
|
||||
# Upgrade packages
|
||||
paru --noconfirm -Syu
|
||||
|
||||
return_code=$?
|
||||
|
||||
# If a kernel update was performed, ask the user to reboot
|
||||
if [[ $has_kernel_update == '0' ]]; then
|
||||
echo -n "Kernel updated. Reboot? [y/N] "
|
||||
read -q resp
|
||||
echo
|
||||
if [[ $resp == 'n' ]]; then
|
||||
echo "Aborting."
|
||||
exit 1
|
||||
fi
|
||||
sudo reboot
|
||||
fi
|
||||
|
||||
exit $return_code
|
||||
Loading…
x
Reference in New Issue
Block a user