Procházet zdrojové kódy

migrate dotfiles here

Noah Vogt před 1 rokem
rodič
revize
ac46dc345d

+ 4 - 0
apply-dotfiles

@@ -0,0 +1,4 @@
+#!/bin/sh
+
+stow --verbose --dotfiles --target="$HOME"/.config dot-config
+stow --verbose --dotfiles --target="$HOME"/.local/bin local-bin

+ 98 - 0
dot-config/aliasrc

@@ -0,0 +1,98 @@
+# adding some colors to the world
+alias ls='ls --color=auto'
+alias grep='grep --color=auto'
+alias ccat='highlight --out-format=ansi' # like cat, but w/ syntax highlighting
+alias diff='diff --color=auto'
+
+# human readable pls
+alias du='du -h'
+alias df='df -h'
+alias free='free -h'
+
+# basic system aliases
+alias p='doas pacman'
+alias sc='doas systemctl'
+alias q='exit'
+alias sw='Hyprland'
+alias ll='ls -l'
+alias la='ls -A'
+
+# faster directory switching
+alias ..='cd ..'
+alias ...='cd ../..'
+alias ....='cd ../../..'
+alias .....='cd ../../../..'
+
+# vim, v -> neovim
+alias vim='nvim'
+alias v='vim'
+
+
+# safety features
+alias rm='rm -i'
+alias cp='cp -i'
+alias mv='mv -i'
+
+# git aliases
+alias gsetkey="git config --add --local core.sshCommand \'ssh -i \$GIT_SSH_KEY\'"
+alias clone="git clone -c core.sshCommand='/usr/bin/ssh -i \$GIT_SSH_KEY'"
+alias gs='git status'
+alias gd='git diff'
+alias gr='git remote -v'
+alias add='git add'
+alias commit='git commit'
+alias fetch='git fetch'
+alias pull='git pull'
+alias push='git push'
+alias log='git log'
+alias remote='git remote'
+alias tag='git tag'
+alias checkout='git checkout'
+alias merge='git merge'
+alias branch='git branch'
+alias lsc='git log --graph --oneline --decorate --all'
+alias lsb="git log --graph --simplify-by-decoration --pretty=format:'%d' --all"
+alias lst="git log --graph --decorate --all --date=short --abbrev-commit --oneline --pretty=format:'%h%x09%an%x09%ad%x09%s'"
+
+# sane ytdl shortcuts
+alias yt="youtube-dl --add-metadata -i"
+alias yta="yt -x -f bestaudio/best/140"
+alias ytas='yta "$(paste | sed "s/\?.*$//")"'
+
+alias loc='find -type f | grep -v "^./.git" | xargs wc -l | sort -h'
+
+# fast dir switching
+s() {
+    cd "$(ls -d ~/.local/src/* | fzf)"
+}
+
+b() {
+    file="$(ls ~/.local/bin/* | fzf)"
+    [ -n "$file" ] && "$EDITOR" "$file"
+}
+
+c() {
+    pushd "$HOME/.local/src/videopc-infra" > /dev/null || exit 1
+    file="$(find dot-config -type f | fzf)"
+    [ -n "$file" ] &&
+        "$EDITOR" "${file/dot-config\//${XDG_CONFIG_HOME:-$HOME/.config}/}"
+    popd > /dev/null
+}
+
+
+# useful extended system aliases
+alias perm="stat -c \"%a %n\" --"
+installedsize() {
+    pacman -Qi | egrep '^(Name|Installed)' | cut -f2 -d':' | sed 's/^ //' | \
+    grep -A1 "$1" | grep -v "\-\-" | \
+    awk '{ printf "%s%s", $0, (NR%2==1 ? FS : RS) }' | column -t
+}
+etouch() {
+    [ -n "$1" ] && touch "$1" chmod +x "$1"
+}
+evim() {
+    [ -n "$1" ] && touch "$1" && chmod +x "$1" && v "$1"
+}
+mkcd() {
+    [ -n "$1" ] && mkdir "$1" && cd "$1"
+}

+ 8 - 0
dot-config/exportrc

@@ -0,0 +1,8 @@
+# setting basic variables
+export EDITOR=nvim
+export VISUAL=nvim
+export PATH=$PATH:~/.local/bin
+export SHELL=/bin/zsh
+
+# ~/ cleanup
+export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc"

+ 95 - 0
dot-config/hypr/hyprland.conf

@@ -0,0 +1,95 @@
+$mainMod = SUPER
+
+# MONITOR CONFIG
+monitor=,preferred,auto,1
+monitor=,addreserved, 0, 0, 0, 0
+input {
+    # Keyboard
+    kb_layout = ch
+    kb_options = caps:swapescape,altwin:swap_lalt_lwin
+    numlock_by_default = true
+    repeat_delay = 250
+    repeat_rate = 35
+}
+
+binds {
+    scroll_event_delay = 0
+}
+
+general {
+    cursor_inactive_timeout 0
+    # max_fps = 75
+    # Gaps and border
+    gaps_in = 0
+    gaps_out = 0
+    gaps_workspaces = 50
+    border_size = 0
+
+    # Functionality
+    # resize_on_border = true
+    no_focus_fallback = true
+    layout = master
+
+    allow_tearing = false # some guy told me tearing might make things smoother idk
+}
+
+
+animations {
+    enabled = false
+}
+
+misc {
+    vfr = true
+    vrr = 1
+    animate_manual_resizes = false
+    enable_swallow = true
+
+    disable_hyprland_logo = true
+    background_color = rgb(000000)
+    new_window_takes_over_fullscreen = 2
+}
+
+debug {
+	#overlay = true
+	#damage_tracking = 0
+
+	#damage_blink = yes
+}
+
+######## Window rules ########
+windowrule = workspace 1 silent, title:^(pulpit_in)(.*)$
+windowrule = workspace 2 silent, title:^(rtmp_in)(.*)$
+
+
+####### Keybinds ########
+bind = Super, Return, exec, kitty
+bind = Super, E, exec, nautilus --new-window
+bind = Super, 1, workspace, 1
+bind = Super, 2, workspace, 2
+bind = Super, 3, workspace, 3
+bind = Super, 4, workspace, 4
+bind = Super, 5, workspace, 5
+bind = Super, 6, workspace, 6
+bind = Super, 7, workspace, 7
+bind = Super, 8, workspace, 8
+bind = Super, 9, workspace, 9
+bind = Super, 0, workspace, 10
+bind = Super Shift, 1, movetoworkspacesilent, 1
+bind = Super Shift, 2, movetoworkspacesilent, 2
+bind = Super Shift, 3, movetoworkspacesilent, 3
+bind = Super Shift, 4, movetoworkspacesilent, 4
+bind = Super Shift, 5, movetoworkspacesilent, 5
+bind = Super Shift, 6, movetoworkspacesilent, 6
+bind = Super Shift, 7, movetoworkspacesilent, 7
+bind = Super Shift, 8, movetoworkspacesilent, 8
+bind = Super Shift, 9, movetoworkspacesilent, 9
+bind = Super Shift, 0, movetoworkspacesilent, 10
+bind = Super, F, fullscreen, 0
+bind = SuperShift, F, fakefullscreen, 0
+bind = Super, Q, killactive,
+bind = SuperShift, Q, exec, gracefully-quit-all-hypr-windows; hyprctl clients | grep -q "mapped:\s*1" || killall Hyprland
+bind = SuperCtrl, Q, exec, killall Hyprland
+
+exec-once=[workspace 4 silent] kitty -e videopc_api
+exec-once=[workspace 4 silent] kitty -e show-rtmp-in
+exec-once=[workspace 4 silent] kitty -e show-pulpit-in

+ 65 - 0
dot-config/kitty/kitty.conf

@@ -0,0 +1,65 @@
+# disable network connections
+update_check_interval 0
+
+# stop disable confirm to quit dialog
+confirm_os_window_close 0
+
+# disable terminal bell
+enable_audio_bell no
+
+# font
+font_family      JetBrainsMono Nerd Font
+font_size 12.0
+
+# cursor
+cursor #add8e6
+cursor_blink_interval 0
+
+# gui
+window_padding_width 3
+
+# urls
+url_color #0087bd
+url_style curly
+
+# colors
+
+foreground #e4e1e6
+background #1b1b1f
+
+selection_foreground #000000
+selection_background #fffacd
+
+color0 #3b4252
+color1 #bf616a
+color2 #a3be8c
+color3 #ebcb8b
+color4 #81a1c1
+color5 #b48ead
+color6 #88c0d0
+color7 #e5e9f0
+
+color8 #3b4252
+color9 #bf616a
+color10 #a3be8c
+color11 #ebcb8b
+color12 #81a1c1
+color13 #b48ead
+color14 #88c0d0
+color15 #e5e9f0
+
+# keybinds
+clear_all_shortcuts	yes
+
+map alt+c copy_to_clipboard
+map alt+v paste_from_clipboard
+
+map alt+k scroll_line_up
+map alt+j scroll_line_down
+
+map alt+u scroll_page_up
+map alt+d scroll_page_down
+
+map alt+shift+k change_font_size all +1.0
+map alt+shift+j change_font_size all -1.0
+map alt+0 change_font_size all 0

+ 2 - 0
dot-config/mpv/mpv.conf

@@ -0,0 +1,2 @@
+hwdec=auto
+fs=yes

+ 16 - 0
dot-config/readline/inputrc

@@ -0,0 +1,16 @@
+set editing-mode vi
+$if mode=vi
+
+set keymap vi-command
+# these are for vi-command mode
+Control-l: clear-screen
+
+set keymap vi-insert
+# these are for vi-insert mode
+Control-l: clear-screen 
+$endif
+
+# different cursor dependig on editing mode
+set show-mode-in-prompt on
+set vi-cmd-mode-string "\1\e[2 q\2"
+set vi-ins-mode-string "\1\e[6 q\2"

+ 15 - 0
dot-config/user-dirs.dirs

@@ -0,0 +1,15 @@
+# This file is written by xdg-user-dirs-update
+# If you want to change or add directories, just edit the line you're
+# interested in. All local changes will be retained on the next run.
+# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped
+# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an
+# absolute path. No other format is supported.
+# 
+XDG_DOCUMENTS_DIR="$HOME/dox"
+XDG_DOWNLOAD_DIR="$HOME/dl"
+XDG_MUSIC_DIR="$HOME/mus"
+XDG_PICTURES_DIR="$HOME/pix"
+XDG_VIDEOS_DIR="$HOME/vids"
+XDG_DESKTOP_DIR="$HOME/.local/share/desktop"
+XDG_TEMPLATES_DIR="$HOME/.local/share/templates"
+XDG_PUBLICSHARE_DIR="$HOME/.local/share/public"

+ 161 - 0
dot-config/zsh/.zshrc

@@ -0,0 +1,161 @@
+# Enable colors and change prompt:
+autoload -U colors && colors
+PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
+
+# History in cache directory:
+HISTSIZE=10000
+SAVEHIST=10000
+HISTFILE=~/.cache/zsh/history
+
+# Basic auto/tab complete:
+autoload -U compinit
+zstyle ':completion:*' menu select
+zmodload zsh/complist
+compinit
+_comp_options+=(globdots)		# Include hidden files.
+
+# vi mode
+bindkey -v
+export KEYTIMEOUT=1
+
+# Use vim keys in tab complete menu:
+bindkey -M menuselect 'h' vi-backward-char
+bindkey -M menuselect 'k' vi-up-line-or-history
+bindkey -M menuselect 'l' vi-forward-char
+bindkey -M menuselect 'j' vi-down-line-or-history
+bindkey -v '^?' backward-delete-char
+
+# Change cursor shape for different vi modes.
+function zle-keymap-select {
+  if [[ ${KEYMAP} == vicmd ]] ||
+     [[ $1 = 'block' ]]; then
+    echo -ne '\e[1 q'
+  elif [[ ${KEYMAP} == main ]] ||
+       [[ ${KEYMAP} == viins ]] ||
+       [[ ${KEYMAP} = '' ]] ||
+       [[ $1 = 'beam' ]]; then
+    echo -ne '\e[5 q'
+  fi
+}
+zle -N zle-keymap-select
+zle-line-init() {
+    zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
+    echo -ne "\e[5 q"
+}
+zle -N zle-line-init
+echo -ne '\e[5 q' # Use beam shape cursor on startup.
+preexec() { echo -ne '\e[5 q' ;} # Use beam shape cursor for each new prompt.
+
+# Use lf to switch directories and bind it to ctrl-o
+lfcd () {
+    tmp="$(mktemp)"
+    lfub -last-dir-path="$tmp" "$@"
+    if [ -f "$tmp" ]; then
+        dir="$(cat "$tmp")"
+        rm -f "$tmp"
+        [ -d "$dir" ] && [ "$dir" != "$(pwd)" ] && cd "$dir"
+    fi
+}
+bindkey -s '^o' 'lfcd\n'
+
+# Edit line in vim with ctrl-e:
+autoload edit-command-line; zle -N edit-command-line
+bindkey '^e' edit-command-line
+
+# Load aliases and shortcuts if existent.
+[ -f "$HOME/.config/exportrc" ] && source "$HOME/.config/exportrc"
+[ -f "$HOME/.config/aliasrc" ] && source "$HOME/.config/aliasrc"
+[ -f "$HOME/.config/norisa.local" ] && source "$HOME/.config/norisa.local"
+
+if echo $USER | grep -q "miner"; then
+    if cat /tmp/norisa/currently-mining | grep -q "0"; then
+        echo "Start mining ..."
+        echo "1" > /tmp/norisa/currently-mining
+        nmine start
+    fi
+fi
+
+# This is the list for lf icons:
+export LF_ICONS="di=📁:\
+fi=📃:\
+tw=🤝:\
+ow=📂:\
+ln=⛓:\
+or=❌:\
+ex=🎯:\
+*.txt=✍:\
+*.mom=✍:\
+*.me=✍:\
+*.ms=✍:\
+*.png=🖼:\
+*.webp=🖼:\
+*.ico=🖼:\
+*.jpg=📸:\
+*.jpe=📸:\
+*.jpeg=📸:\
+*.gif=🖼:\
+*.svg=🗺:\
+*.tif=🖼:\
+*.tiff=🖼:\
+*.xcf=🖌:\
+*.html=🌎:\
+*.xml=📰:\
+*.gpg=🔒:\
+*.css=🎨:\
+*.pdf=📚:\
+*.djvu=📚:\
+*.epub=📚:\
+*.csv=📓:\
+*.xlsx=📓:\
+*.tex=📜:\
+*.md=📘:\
+*.r=📊:\
+*.R=📊:\
+*.rmd=📊:\
+*.Rmd=📊:\
+*.m=📊:\
+*.mp3=🎵:\
+*.opus=🎵:\
+*.ogg=🎵:\
+*.m4a=🎵:\
+*.flac=🎼:\
+*.wav=🎼:\
+*.mkv=🎥:\
+*.mp4=🎥:\
+*.webm=🎥:\
+*.mpeg=🎥:\
+*.avi=🎥:\
+*.mov=🎥:\
+*.mpg=🎥:\
+*.wmv=🎥:\
+*.m4b=🎥:\
+*.flv=🎥:\
+*.zip=📦:\
+*.rar=📦:\
+*.7z=📦:\
+*.tar.gz=📦:\
+*.z64=🎮:\
+*.v64=🎮:\
+*.n64=🎮:\
+*.gba=🎮:\
+*.nes=🎮:\
+*.gdi=🎮:\
+*.1=ℹ:\
+*.nfo=ℹ:\
+*.info=ℹ:\
+*.log=📙:\
+*.iso=📀:\
+*.img=📀:\
+*.bib=🎓:\
+*.ged=👪:\
+*.part=💔:\
+*.torrent=🔽:\
+*.jar=♨:\
+*.java=♨:\
+"
+
+# fish-like zsh autosuggestions
+source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
+
+# Load zsh-syntax-highlighting; should be last.
+source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 2>/dev/null

+ 19 - 0
local-bin/get-pulpit-device

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+devices="$(v4l2-ctl --list-devices)"
+
+if echo "$devices" | grep -q "^Cam Link"; then
+    device="Cam Link"
+else
+    device="USB Video"
+fi
+
+possible_streams="$(v4l2-ctl --list-devices | grep "^$device" -A 20 | \
+                    grep "^\s*/dev/" | sed 's/^\s*//')"
+
+[ -z "$possible_streams" ] && exit
+
+while IFS= read -r stream; do
+    doas v4l2-ctl --device="$stream" --all | grep -q "^Video input" &&
+    echo "$stream" && exit
+done <<< "$possible_streams"

+ 4 - 0
local-bin/gracefully-quit-all-hypr-windows

@@ -0,0 +1,4 @@
+#!/bin/sh
+
+HYPRCMDS=$(hyprctl -j clients | jq -j '.[] | "dispatch closewindow address:\(.address); "')
+hyprctl --batch "$HYPRCMDS"

+ 5 - 0
local-bin/internal-ip

@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# script to display the internal ip of the current connected network
+
+ip a | grep "inet 192" | tr '/' ' ' | awk '{print $2}'

+ 8 - 0
local-bin/show-pulpit-in

@@ -0,0 +1,8 @@
+#!/bin/sh
+
+while true; do
+    mpv "$(~/.local/bin/get-pulpit-device)" --no-cache --untimed \
+        --no-demuxer-thread --video-sync=audio --vd-lavc-threads=1 \
+        --no-resume-playback --title="pulpit_in"
+        sleep 0.5
+done

+ 10 - 0
local-bin/show-rtmp-in

@@ -0,0 +1,10 @@
+#!/bin/sh
+
+RTMP_KEY="$(cat /etc/videopc_rtmp_key)"
+
+while true; do
+    mpv rtmp://localhost:1935/live/"$RTMP_KEY" --no-cache --untimed \
+        --no-demuxer-thread --video-sync=audio --vd-lavc-threads=1 \
+        --no-resume-playback --title="rtmp_in"
+        sleep 0.5
+done

+ 4 - 0
local-bin/videopc_api

@@ -0,0 +1,4 @@
+#!/bin/sh
+
+cd "$HOME"/.local/bin || exit 1
+uvicorn videopc_api:api --host "$(~/.local/bin/internal-ip)" | logger -p 1

+ 52 - 0
local-bin/videopc_api.py

@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+
+from os import system
+
+from fastapi import FastAPI
+
+api = FastAPI()
+
+with open("/etc/videopc_api_key", "r") as api_file_reader:
+    SECRET = api_file_reader.read().strip()
+
+
+@api.get("/" + SECRET + "/test_connection")
+async def test_connection():
+    # TODO: check if daemons are running
+    return {"api_online": 1}
+
+
+@api.get("/" + SECRET + "/input/pulpit")
+def switch_to_pulpit_in():
+    system("hyprctl dispatch workspace 1")
+    return {"success": 1}
+
+
+@api.get("/" + SECRET + "/input/rtmp")
+def switch_to_rtmp_in():
+    system("hyprctl dispatch workspace 2")
+    return {"success": 1}
+
+
+@api.get("/" + SECRET + "/input/black_screen")
+def switch_to_blackscreen():
+    system("hyprctl dispatch workspace 3")
+    return {"success": 1}
+
+
+@api.get("/" + SECRET + "/power/suspend")
+def suspend_videopc():
+    system("systemctl suspend")
+    return {"success": 1}
+
+
+@api.get("/" + SECRET + "/power/shutdown")
+def shutdown_videopc():
+    system("shutdown now")
+    return {"success": 1}
+
+
+@api.get("/" + SECRET + "/power/reboot")
+def reboot_videopc():
+    system("reboot")
+    return {"success": 1}

+ 2 - 2
videopc-bootstrap.sh

@@ -174,7 +174,7 @@ if [ ! -d /home/"$username"/.local/src/dotfiles ]; then
     echo -e "\e[0;30;34mFetching dotfiles ...\e[0m"
     cd_into /home/"$username"/.local/src
     while true; do
-        git clone https://git.noahvogt.com/noah/videopc-dotfiles.git && break
+        git clone https://git.noahvogt.com/noah/videopc-infra.git && break
     done
 else
     echo -e "\e[0;30;34mUpdating dotfiles ...\e[0m"
@@ -183,7 +183,7 @@ else
         git pull && break
     done
 fi
-mv /home/"$username"/.local/src/videopc-dotfiles /home/"$username"/.local/src/dotfiles
+mv /home/"$username"/.local/src/videopc-infra /home/"$username"/.local/src/dotfiles
 cd_into /home/"$username"/.local/src/dotfiles
 echo -e "\e[0;30;34mApplying dotfiles ...\e[0m"
 doas -u "$username" /home/"$username"/.local/src/dotfiles/apply-dotfiles