diff --git a/bash/.bash_functions b/bash/.bash_functions index 8fb2330..7040de0 100644 --- a/bash/.bash_functions +++ b/bash/.bash_functions @@ -44,6 +44,19 @@ vifmmv() { cd "$dst" } +# Open command script in vim +viw() { + if [[ -z "$1" ]] || ! which "$1"; then + printf "No %s found in path\nAborting...\n" "$1" + exit 1 + elif [[ "$(file "$(which "$1")")" =~ 'ELF.*executable' ]]; then + printf "%s is a binary\nAborting...\n" "$1" + exit 1 + else + "$EDITOR" "$(which "$1")" + fi +} + # Better exiting ==================================================== # Don't exit with background jobs still running. Particularly for Qemu function exit () { diff --git a/bin/battery_status.sh b/bin/battery_status.sh index 44b01ca..44418fe 100755 --- a/bin/battery_status.sh +++ b/bin/battery_status.sh @@ -24,8 +24,6 @@ upower --dump | awk ' else printf "==== %s ========\n", device[dev]["name"]; - asort(device[dev]); - for (i in device[dev]) { is_name = (tolower(device[dev][i]) ~ /(device|model)/); is_label = (device[dev][i] ~ /:/); diff --git a/sway/config b/sway/config index 5389817..5f95cec 100644 --- a/sway/config +++ b/sway/config @@ -244,7 +244,7 @@ output DP-3 scale 2 default_border pixel 2 # Adjust gamma. More important for external displays. Laptops are usually fine -exec wlsunset -t 4000 -T 6500 -g 0.9 +exec wlsunset -t 6499 -T 6500 -g 0.9 # Volume controls bindsym XF86AudioRaiseVolume exec $volume_command 4 $volume_notify_sound diff --git a/swaylock/config b/swaylock/config index 30be9c1..36198d0 100644 --- a/swaylock/config +++ b/swaylock/config @@ -2,6 +2,9 @@ show-failed-attempts image=~/.config/swaylock/default_wallpaper.png bs-hl-color=83A598 +scaling=fit +color=000000 + indicator-radius=60 indicator-thickness=20 diff --git a/vifm/scripts/vifm_bg_open.sh b/vifm/scripts/vifm_bg_open.sh index 0c5a436..4dd6845 100755 --- a/vifm/scripts/vifm_bg_open.sh +++ b/vifm/scripts/vifm_bg_open.sh @@ -1,48 +1,84 @@ #!/usr/bin/env bash print_help() { cat <&2 + exit 1 +} + +open_pdf() { + zathura "$1" & +} + +open_image() { + imv "$1" & +} + +open_av_media() { + local has_video="$(ffprobe -hide_banner "$1" 2>&1 | awk '/Stream.+Video/')" + + if [[ -n "$TMUX" && -z "$has_video" ]] || [[ ! $is_gui && -n "$TMUX" ]]; then + tmux split-window -h + sleep .2 # Let bash login, otherwise command won't get sent + tmux send-keys "mpv $1" Enter + elif [[ $is_gui ]]; then + mpv --force-window "$1" &>/dev/null & + fi +} + +open_webpage() { + chromium "$1" &>/dev/null & +} + +open_vim() { + tmux new-window -c "#{pane_current_path}" + sleep .2 # Let bash login, otherwise command won't get sent + tmux send-keys "vi $1" Enter +} + open_file() { case "${1##*.}" in pdf) - zathura "$1" & + if [[ $is_gui ]]; then + open_pdf "$1" + else + requires_gui_error + fi ;; avif|icns|jpeg|jpg|png|webp) - imv "$1" & + if [[ $is_gui ]]; then + open_image "$1" + else + requires_gui_error + fi ;; mkv|mp3|mp4|webm) - local has_video="$(ffprobe -hide_banner "$1" 2>&1 | awk '/Stream.+Video/')" - - if [[ -n "$TMUX" && -z "$has_video" ]]; then - tmux split-window -h - sleep .2 # Let bash login, otherwise command won't get sent - tmux send-keys "mpv $1" Enter - else - mpv --force-window "$1" &>/dev/null & - fi + open_av_media "$1" ;; html) - chromium "$1" &>/dev/null & + if [[ $is_gui ]]; then + open_webpage "$1" + else + requires_gui_error + fi ;; *) - if [[ -n "$TMUX" ]] && file "$1" | grep -iq 'ascii'; then - tmux new-window -c "#{pane_current_path}" - sleep .2 # Let bash login, otherwise command won't get sent - tmux send-keys "vi $1" Enter + if [[ -n "$TMUX" && -f "$1" && "$(stat -c%s "$1")" -le 1000000 ]]; then + open_vim "$1" fi + ;; esac } -if [[ -z ${SWAYSOCK+x} ]]; then - printf 'Sway not running. Will not open gui apps\n' >&2 - exit 1 -fi - for arg in "$@" do case "$arg" in @@ -55,5 +91,3 @@ do ;; esac done - -#swaymsg [con_mark=vifm_window] focus diff --git a/vifm/vifmrc b/vifm/vifmrc index 71d267f..dd264fa 100644 --- a/vifm/vifmrc +++ b/vifm/vifmrc @@ -270,9 +270,9 @@ command! fdcddir command! fdeditfiles \ :if $TMUX != '' && &columns > 90 - \ | exe 'edit "'.system('fd -HE ''.git'' -t f . | fzf-tmux -p 90,30').'"' + \ | exe '!~/.configs_pointer/vifm/scripts/vifm_bg_open.sh "'.system('fd -HE ''.git'' -t f . | fzf-tmux -p 90,30').'"' \ | else - \ | exe 'edit "'.term('fd -HE ''.git'' -t f . | fzf 2>/dev/tty').'"' + \ | exe '!~/.configs_pointer/vifm/scripts/vifm_bg_open.sh "'.term('fd -HE ''.git'' -t f . | fzf 2>/dev/tty').'"' \ | endif command! fdmvcursor @@ -328,7 +328,7 @@ fileviewer *[^/] env -uCOLORTERM bat --color always --theme ansi --wrap never -- filetype *.mp4,*.mkv,*.mov,*.webm,*.mp3,*.flac mpv %c -if system('uname') == 'Darwin' +if system('uname -s') == 'Darwin' filetype *.jpg,*.jpeg,*.png,*.icns open -a Preview.app %c:p filetype *.pdf open -a 'skim' %c || open %c:p else