diff --git a/.gitignore b/.gitignore index a47af7b..bec655b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ /* -!.git* !LICENSE.md !README.md @@ -8,6 +7,7 @@ !clangd/ !git/ !highlight/ +!i3/ !pgcli/ !ranger/ !remmina/ diff --git a/alacritty/alacritty.toml b/alacritty/alacritty.toml index 7ce348d..f5fe3fb 100644 --- a/alacritty/alacritty.toml +++ b/alacritty/alacritty.toml @@ -9,7 +9,7 @@ render_timer = false TERM = "alacritty" [font] -size = 11.0 +size = 9.0 [font.normal] family = "SourceCodePro" diff --git a/git/config b/git/config index e051db0..499929f 100644 Binary files a/git/config and b/git/config differ diff --git a/i3/background.png b/i3/background.png new file mode 100644 index 0000000..1f48b0c Binary files /dev/null and b/i3/background.png differ diff --git a/i3/config b/i3/config new file mode 100644 index 0000000..4d61da1 --- /dev/null +++ b/i3/config @@ -0,0 +1,178 @@ +set $mod Mod1 + +set $left h +set $down j +set $up k +set $right l +set $LEFT H +set $DOWN J +set $UP K +set $RIGHT L + +set $config config +set $term alacritty +set $system [l] lock, [e] exit, [h] hibernate, [r] reboot, [s] shutdown +set $scrot [w] clip window, [c-w] save window, [a] clip area, [c-a] save area +set $now $(date +%Y%m%d%H%M%S) +set $scripts $HOME/.config/scripts +set $background $HOME/.config/i3/background.png + +# Font for window titles. Will also be used by the bar unless a different font +# is used in the bar {} block below. +font pango:SourceCodePro 10 + +# exec_always wired +exec_always xset r rate 300 50 +exec_always xrandr --output eDP --mode 1440x900 +exec_always setxkbmap gb +exec_always setxkbmap -option "ctrl:nocaps" +exec_always --no-startup-id xss-lock -l -- i3lock -i $background --nofork + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# move tiling windows via drag & drop by left-clicking into the title bar, +# or left-clicking anywhere into the window while holding the floating modifier. +tiling_drag modifier titlebar + +# Kill focused window +bindsym $mod+Shift+q kill + +# Reload the configuration file +bindsym $mod+Control+r reload + +# Start a terminal +bindsym $mod+Return exec $term + +# Start a tmux session in a new terminal +bindsym $mod+Shift+Return exec $term -e tmux -u + +# Start launcher +bindsym $mod+d exec rofi -show drun -theme windows/run + +# Open Kubernetes context menu +# bindsym $mod+c exec $scripts/context + +# Open lpass password menu +bindsym $mod+p exec $scripts/lpass password + +# Open lpass notes menu +bindsym $mod+o exec $scripts/lpass notes + +bindsym $mod+i exec $scripts/lpass id + +bindsym $mod+Shift+0 exec i3lock -i $background + +bindsym $mod+Shift+i exec $scripts/lpass sh + +# Generate password +bindsym $mod+Shift+p exec $scripts/pwgen + +# A more modern dmenu replacement is rofi: +# bindcode $mod+40 exec "rofi -modi drun,run -show drun" +# There also is i3-dmenu-desktop which only displays applications shipping a +# .desktop file. It is a wrapper around dmenu, so you need that installed. +# bindcode $mod+40 exec --no-startup-id i3-dmenu-desktop + +# change focus +bindsym $mod+$left focus left +bindsym $mod+$down focus down +bindsym $mod+$up focus up +bindsym $mod+$right focus right + +bindsym $mod+Shift+$left move left +bindsym $mod+Shift+$down move down +bindsym $mod+Shift+$up move up +bindsym $mod+Shift+$right move right + +# split in horizontal orientation +bindsym $mod+x split horizontal +bindsym $mod+v split vertical + +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen toggle + +# change container layout (stacked, tabbed, toggle split) +bindsym $mod+s layout stacking +bindsym $mod+w layout tabbed +bindsym $mod+e layout toggle split + +# toggle tiling / floating +bindsym $mod+Shift+space floating toggle + +# change focus between tiling / floating windows +bindsym $mod+space focus mode_toggle + +# focus the parent container +bindsym $mod+a focus parent + +# focus the child container +#bindsym $mod+d focus child + +# Define names for default workspaces for which we configure key bindings later on. +# We use variables to avoid repeating the names in multiple places. +set $ws1 "1" +set $ws2 "2" +set $ws3 "3" +set $ws4 "4" +set $ws5 "5" +set $ws6 "6" +set $ws7 "7" +set $ws8 "8" +set $ws9 "9" + +# switch to workspace +bindsym $mod+1 workspace number $ws1 +bindsym $mod+2 workspace number $ws2 +bindsym $mod+3 workspace number $ws3 +bindsym $mod+4 workspace number $ws4 +bindsym $mod+5 workspace number $ws5 +bindsym $mod+6 workspace number $ws6 +bindsym $mod+7 workspace number $ws7 +bindsym $mod+8 workspace number $ws8 +bindsym $mod+9 workspace number $ws9 + +# move focused container to workspace +bindsym $mod+Shift+1 move container to workspace number $ws1 +bindsym $mod+Shift+2 move container to workspace number $ws2 +bindsym $mod+Shift+3 move container to workspace number $ws3 +bindsym $mod+Shift+4 move container to workspace number $ws4 +bindsym $mod+Shift+5 move container to workspace number $ws5 +bindsym $mod+Shift+6 move container to workspace number $ws6 +bindsym $mod+Shift+7 move container to workspace number $ws7 +bindsym $mod+Shift+8 move container to workspace number $ws8 +bindsym $mod+Shift+9 move container to workspace number $ws9 + +# reload the configuration file +bindsym $mod+Shift+c reload +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym $mod+Shift+r restart +# exit i3 (logs you out of your X session) +bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'Exit?' -B 'Yes, exit i3' 'i3-msg exit'" + +bindsym XF86MonBrightnessUp exec brightnessctl s +10 +bindsym XF86MonBrightnessDown exec brightnessctl s 10- + +# resize window (you can also use the mouse for that) +mode "resize" { + bindsym j resize shrink width 10 px or 10 ppt + bindsym k resize grow height 10 px or 10 ppt + bindsym l resize shrink height 10 px or 10 ppt + bindsym semicolon resize grow width 10 px or 10 ppt + + bindsym Left resize shrink width 10 px or 10 ppt + bindsym Down resize grow height 10 px or 10 ppt + bindsym Up resize shrink height 10 px or 10 ppt + bindsym Right resize grow width 10 px or 10 ppt + + bindsym Return mode "default" + bindsym Escape mode "default" + bindsym $mod+r mode "default" +} + +bindsym $mod+r mode "resize" + +bar { + position top + status_command $HOME/.config/scripts/status +} diff --git a/nvim b/nvim index 4c4dea6..0910770 160000 --- a/nvim +++ b/nvim @@ -1 +1 @@ -Subproject commit 4c4dea6c396d7bec5d4f73ac529ca5f0386b0ab3 +Subproject commit 0910770a6241b791e5b6f89171123913cca36860 diff --git a/scripts/lock b/scripts/lock index b569a23..31544be 100755 --- a/scripts/lock +++ b/scripts/lock @@ -1,18 +1,19 @@ #!/bin/bash -toggle_output() { - swaymsg output "DP-${1}" dpms toggle -} +i3lock -c 222222 -toggle_vertical_displays() { - toggle_output 1 - toggle_output 2 -} - -toggle_vertical_displays - -trap "toggle_vertical_displays" SIGUSR1 - -swaylock -Fetc '#000000' - -toggle_vertical_displays +# i3lock -c 222222 -e & +# +# pid=$$ +# +# log() { +# echo "[$(date -I)] ${1}" >> /var/log/lock.log +# } +# +# until ! kill -0 $pid || fprintd-verify; do +# log "Fingerprint failure" +# done +# +# log "Login success" +# +# kill $pid diff --git a/scripts/status b/scripts/status index ab434f4..46a4258 100755 --- a/scripts/status +++ b/scripts/status @@ -1,5 +1,6 @@ #!/usr/bin/env python +import re from subprocess import run from datetime import datetime, timedelta from time import sleep @@ -7,7 +8,8 @@ from sys import stdout from typing import Callable def future_time() -> datetime: - return datetime.now() + timedelta(seconds = 10) + # return datetime.now() + timedelta(seconds = 10) + return datetime.now() + timedelta(seconds = 1) def cmd(args: list[str]) -> str: proc = run(args, capture_output = True) @@ -17,6 +19,23 @@ def cmd(args: list[str]) -> str: def libvirtd_status() -> str: return cmd(["systemctl", "is-active", "libvirtd.service"]) +def bat_cap() -> str: + return cmd(["cat", "/sys/class/power_supply/BAT0/capacity"]) + +def wifi() -> str: + proc = run(["iwctl", "station", "wlan0", "show"], capture_output = True) + lines = proc.stdout.decode("utf-8").splitlines() + cols = re.split(r"\s+", lines[6]) + + return cols[3] + +def brightness() -> str: + proc = run(["brightnessctl", "g"], capture_output = True) + level = int(proc.stdout.decode("utf-8")) + perc = (level / 255) * 100 + + return int(perc) + def virt_state(name: str) -> str: return cmd(["virsh", "--connect", "qemu:///system", "domstate", name]) @@ -33,10 +52,13 @@ after: datetime = future_time() state: dict[str, str | int] = dict() deletions: list[str] = [] renderers: dict[str, Callable[[], str | int]] = { - "kubernetes": lambda: k_context(), - "bluetooth": lambda: dev_count(), - "bindows": lambda: virt_state("bindows"), - "libvirtd": lambda: libvirtd_status() + # "kubernetes": lambda: k_context(), + # "bluetooth": lambda: dev_count(), + # "bindows": lambda: virt_state("bindows"), + # "libvirtd": lambda: libvirtd_status(), + "wifi": lambda: wifi(), + "bat": lambda: bat_cap(), + "dim": lambda: brightness() } for k in renderers: diff --git a/zsh/init.zsh b/zsh/init.zsh index f128bd9..c1bae09 100644 --- a/zsh/init.zsh +++ b/zsh/init.zsh @@ -29,13 +29,20 @@ plugins=( fzf-marks ) -# Managers -source "${ZSH}/oh-my-zsh.sh" -source "${NVM_DIR}/nvm.sh" +# Omg My ZSH +if [[ -d "$ZSH" ]]; then + source "${ZSH}/oh-my-zsh.sh" +fi -# Modules -source "${ZSH_DIR}/aliases.zsh" -source "${ZSH_DIR}/utils.zsh" +# ZSH modules +if [[ -d "$ZSH_DIR" ]]; then + source "${ZSH_DIR}/aliases.zsh" + source "${ZSH_DIR}/utils.zsh" +fi + +if [[ -d "$NVM_DIR" ]]; then + source "${NVM_DIR}/nvm.sh" +fi # Google Cloud if [[ -d "$GCLOUD_PATH" ]]; then @@ -74,8 +81,8 @@ eval $(just --completions zsh) ssh-add -q ~/.keys/ssh/marziply/prv.pem lpass sync -b --color never -generate_marks -start_sway +genmarks +startwm rm -rf \ "${HOME}/Documents" \ @@ -83,6 +90,3 @@ rm -rf \ "${HOME}/Music" \ "${HOME}/Videos" \ "${HOME}/Pictures" - -# bun completions -[ -s "/home/hayden/.config/bun/_bun" ] && source "/home/hayden/.config/bun/_bun" diff --git a/zsh/utils.zsh b/zsh/utils.zsh index 7b49193..42c73aa 100644 --- a/zsh/utils.zsh +++ b/zsh/utils.zsh @@ -8,17 +8,17 @@ default_marks=( "work : ${HOME}/dev/work" ) -start_sway() { +startwm() { local current_tty="$(tty)" if [[ "$current_tty" =~ ^/dev/tty[0-9]+$ ]]; then if [[ "${current_tty: -1}" == "1" ]]; then - sway + startx /usr/bin/i3 fi elif [[ -z "$SSH_CLIENT" && -z "$SSH_TTY" ]]; then - tmux source-file "${TMUX_DIR}/tmux.conf" + tmux source-file "${TMUX_DIR}/tmux.conf" &> /dev/null else - echo "foo" + # @TODO: Possibly an SSH client fi # if ! systemctl -q is-active libvirtd.service; then @@ -26,8 +26,8 @@ start_sway() { # fi } -generate_marks() { - dirs=$(stat ${HOME}/dev/{lab,lib,work}/* -c '%Y %n' | sort -r) +genmarks() { + dirs=`find $HOME/* -maxdepth 2 -type d` dirs_count=$(echo $dirs | wc -l) total_marks=$(cat $marks_list | wc -l) marks_count=$(($total_marks - ${#default_marks})) @@ -35,10 +35,10 @@ generate_marks() { if [[ "$dirs_count" != "$marks_count" ]]; then printf '%s\n' "${default_marks[@]}" >$marks_list - echo "$dirs" | - cut -d ' ' -f 2 | - xargs -I % bash -c 'echo "$(grep -Po "[^/]+/[^/]+$" <<< "%") : %"' \ - >>$marks_list + echo "$dirs" \ + | cut -d ' ' -f 2 \ + | xargs bash -c 'echo "$(grep -Po "[^/]+/[^/]+$" <<< "{}") : {}"' \ + >> $marks_list fi }