Add more dwm rules, improve fzf workflow

This commit is contained in:
mintycube 2024-06-08 09:14:08 +05:00
parent 0248daeafe
commit 016cf8bad2
14 changed files with 163 additions and 118 deletions

View File

@ -13,6 +13,9 @@ progress_bar_height = 80
progress_bar_frame_width = 1
progress_bar_min_width = 300
progress_bar_max_width = 300
icon =
default_icon =
icon_position=off
indicate_hidden = yes
transparency = 0
separator_height = 1
@ -51,18 +54,27 @@ title = Dunst
class = Dunst
[urgency_low]
icon =
default_icon =
icon_position=off
timeout = 2
background = "#1e1e2e"
foreground = "#a6adc8"
frame_color = "#cba6f7"
[urgency_normal]
icon =
default_icon =
icon_position=off
timeout = 5
background = "#1e1e2e"
foreground = "#a6adc8"
frame_color = "#cba6f7"
[urgency_critical]
icon =
default_icon =
icon_position=off
timeout = 0
background = "#1e1e2e"
foreground = "#a6adc8"

View File

@ -16,7 +16,7 @@ unset command
alias \
be="fzf-fd \$HOME/.local/bin | xargs -r nvim" \
ce="fzf-fd \$HOME/.config | xargs -r nvim" \
ce="confedit" \
cg="fzf-grep \$HOME/.config" \
fe="fzf-fd \$(pwd) | xargs -r nvim" \
fg="fzf-grep \$(pwd)" \

View File

@ -161,30 +161,32 @@ static const Rule rules[] = {
* WM_WINDOW_ROLE(STRING) = role
* _NET_WM_WINDOW_TYPE(ATOM) = wintype
*/
RULE(.wintype = WTYPE "DIALOG", .isfloating = 1)
RULE(.wintype = WTYPE "UTILITY", .isfloating = 1)
RULE(.wintype = WTYPE "TOOLBAR", .isfloating = 1)
RULE(.wintype = WTYPE "SPLASH", .isfloating = 1)
RULE(.wintype = WTYPE "DIALOG", .isfloating = 1)
RULE(.wintype = WTYPE "UTILITY", .isfloating = 1)
RULE(.wintype = WTYPE "TOOLBAR", .isfloating = 1)
RULE(.wintype = WTYPE "SPLASH", .isfloating = 1)
RULE(.class = "firefox", .tags = 1 << 1, .switchtag = 1)
RULE(.title = "nvim", .tags = 1 << 2, .switchtag = 1)
RULE(.title = "lf", .tags = 1 << 3, .switchtag = 1)
RULE(.class = "mpv", .tags = 1 << 4, .switchtag = 3)
RULE(.title = "newsboat", .tags = 1 << 5, .switchtag = 3)
RULE(.class = "Zathura", .tags = 1 << 6, .switchtag = 3)
RULE(.title = "nsxiv", .tags = 1 << 7, .switchtag = 3)
RULE(.class = "Gimp", .tags = 1 << 8, .switchtag = 3)
RULE(.class = "firefox", .tags = 1 << 1, .switchtag = 1)
RULE(.title = "nvim", .tags = 1 << 2, .switchtag = 1)
RULE(.title = "lf", .tags = 1 << 3, .switchtag = 1)
RULE(.class = "mpv", .tags = 1 << 4, .switchtag = 3)
RULE(.title = "newsboat", .tags = 1 << 5, .switchtag = 3)
RULE(.class = "Zathura", .tags = 1 << 6, .switchtag = 3)
RULE(.title = "nsxiv", .tags = 1 << 7, .switchtag = 3)
RULE(.class = "Gimp", .tags = 1 << 8, .switchtag = 3)
RULE(.instance = "libreoffice", .tags = 1 << 8, .switchtag = 3)
RULE(.instance = "spterm", .tags = SPTAG(0), .isfloating = 1)
RULE(.instance = "spcalc", .tags = SPTAG(1), .isfloating = 1)
RULE(.class = "Qalculate-gtk", .tags = SPTAG(2), .isfloating = 1)
RULE(.instance = "spmusic", .tags = SPTAG(3), .isfloating = 1)
RULE(.instance = "spnotes", .tags = SPTAG(4), .isfloating = 1)
RULE(.instance = "spterm", .tags = SPTAG(0), .isfloating = 1)
RULE(.instance = "spterm", .tags = SPTAG(0), .isfloating = 1)
RULE(.instance = "spcalc", .tags = SPTAG(1), .isfloating = 1)
RULE(.class = "Qalculate-gtk", .tags = SPTAG(2), .isfloating = 1)
RULE(.instance = "spmusic", .tags = SPTAG(3), .isfloating = 1)
RULE(.instance = "spnotes", .tags = SPTAG(4), .isfloating = 1)
RULE(.instance = "spterm", .tags = SPTAG(0), .isfloating = 1)
RULE(.instance = "dictionary", .isfloating = 1)
RULE(.class = "volume-ui", .isfloating = 1)
RULE(.class = "gping-ui", .isfloating = 1)
RULE(.instance = "dictionary", .isfloating = 1)
RULE(.class = "volume-ui", .isfloating = 1)
RULE(.class = "gping-ui", .isfloating = 1)
RULE(.class = "PersepolisDM", .title = "(None)None",.isfloating = 1)
};
/* Bar rules allow you to configure what is shown where on the bar, as well as
@ -255,8 +257,8 @@ static const char* volume_ui_cmd[] = { "st", "-c", "volume-ui", "-g=80x15+353+20
static const Key on_empty_keys[] = {
/* modifier key function argument */
{0, XK_e, spawn, SHCMD("st fuz") },
{0, XK_f, spawn, SHCMD("st fuz") },
{0, XK_e, spawn, {.v = (const char*[]){"fuz-launcher", NULL } } },
{0, XK_f, spawn, {.v = (const char*[]){"fuz-launcher", NULL } } },
{0, XK_w, spawn, {.v = (const char*[]){"firefox", NULL } } },
{0, XK_grave, spawn, {.v = (const char*[]){"dmenunerdsymbols", NULL } } },
{0, XK_BackSpace, spawn, {.v = (const char*[]){"sysact", NULL } } },
@ -307,7 +309,7 @@ static const Key keys[] = {
{ MODKEY, XK_q, killclient, {0} },
{ MODKEY|ShiftMask, XK_q, killunsel, {0} },
{ MODKEY, XK_w, spawn, {.v = (const char*[]){ "firefox", NULL } } },
{ MODKEY, XK_e, spawn, SHCMD("st fuz") },
{ MODKEY, XK_e, spawn, {.v = (const char*[]){"fuz-launcher", NULL } } },
{ ALTKEY, XK_e, spawn, {.v = (const char*[]){ "networkmanager_dmenu", NULL } } },
{ MODKEY, XK_r, spawn, {.v = (const char*[]){ "st", "-e", "lf", NULL } } },
{ MODKEY|ShiftMask, XK_r, spawn, {.v = (const char*[]){ "thunar", NULL } } },

View File

@ -0,0 +1,42 @@
!! vim: filetype=xdefaults
*.background: #101010
*.foreground: #b9b9b9
*.cursorColor: #b9b9b9
*.color0: #101010
*.color8: #525252
*.color1: #7c7c7c
*.color9: #7c7c7c
*.color2: #8e8e8e
*.color10: #8e8e8e
*.color3: #a0a0a0
*.color11: #a0a0a0
*.color4: #686868
*.color12: #686868
*.color5: #747474
*.color13: #747474
*.color6: #868686
*.color14: #868686
*.color7: #b9b9b9
*.color15: #f7f7f7
dwm.normbordercolor: #313244
dwm.normbgcolor: #1e1e2e
dwm.normfgcolor: #a6adc8
dwm.selbordercolor: #585b70
dwm.selbgcolor: #7f849c
dwm.selfgcolor: #a6adc8
dwm.tagsnormfgcolor: #a6adc8
dwm.tagsnormbgcolor: #1e1e2e
dwm.tagsselfgcolor: #a6adc8
dwm.tagsselbgcolor: #313244
dmenu.foreground: #a6adc8
dmenu.background: #1e1e2e
dmenu.selforeground: #1e1e2e
dmenu.selbackground: #cba6f7
dmenu.bordercolor: #cba6f7
slock.locked: #45475a
slock.input: #a6adc8
slock.failed: #89b4fa

View File

@ -1,6 +1,6 @@
! vim: filetype=xdefaults
! Choices: tokyonight, rose-pine, onedark,
! Choices: tokyonight, rose-pine, onedark, monochrome
! evergarden, nord, oxocarbon, catpuccin, tokyodark
#include "colors/catpuccin"

View File

@ -1,34 +1,35 @@
#!/usr/bin/env bash
#!/bin/sh
configs=(
"$XDG_CONFIG_HOME/suckless/dmenu/config.h"
"$XDG_CONFIG_HOME/suckless/dwm/config.h"
"$XDG_CONFIG_HOME/suckless/dwmblocks/config.h"
"$XDG_CONFIG_HOME/suckless/st/config.h"
"$XDG_CONFIG_HOME/suckless/slock/config.h"
"$XDG_CONFIG_HOME/x11/xresources"
"$XDG_CONFIG_HOME/nvim/lua"
"$XDG_CONFIG_HOME/zsh/.zshrc"
"$XDG_CONFIG_HOME/shell/aliasrc"
"$XDG_CONFIG_HOME/x11/xinitrc"
"$XDG_CONFIG_HOME/x11/xprofile"
"$HOME/.bashrc"
"$XDG_CONFIG_HOME/mpd/mpd.conf"
"$XDG_CONFIG_HOME/ncmpcpp/config"
"$XDG_CONFIG_HOME/dunst/dunstrc"
"$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0"
"$XDG_CONFIG_HOME/gtk-3.0/settings.ini"
"$XDG_CONFIG_HOME/lf/lfrc"
"$XDG_CONFIG_HOME/newsboat/config"
"$XDG_CONFIG_HOME/newsboat/urls"
"$XDG_CONFIG_HOME/zathura/zathurarc"
"$XDG_DATA_HOME/script-data/keybinds"
"$XDG_CONFIG_HOME/dmenu_web"
)
configs="$XDG_CONFIG_HOME/suckless/dmenu/config.h
$XDG_CONFIG_HOME/suckless/dwm/config.h
$XDG_CONFIG_HOME/suckless/dwmblocks/config.h
$XDG_CONFIG_HOME/suckless/st/config.h
$XDG_CONFIG_HOME/suckless/slock/config.h
$XDG_CONFIG_HOME/x11/xresources
$XDG_CONFIG_HOME/nvim/lua
$XDG_CONFIG_HOME/zsh/.zshrc
$XDG_CONFIG_HOME/shell/aliasrc
$XDG_CONFIG_HOME/x11/xinitrc
$XDG_CONFIG_HOME/x11/xprofile
$HOME/.bashrc
$XDG_CONFIG_HOME/mpd/mpd.conf
$XDG_CONFIG_HOME/ncmpcpp/config
$XDG_CONFIG_HOME/dunst/dunstrc
$XDG_CONFIG_HOME/gtk-2.0/gtkrc-2.0
$XDG_CONFIG_HOME/gtk-3.0/settings.ini
$XDG_CONFIG_HOME/lf/lfrc
$XDG_CONFIG_HOME/newsboat/config
$XDG_CONFIG_HOME/newsboat/urls
$XDG_CONFIG_HOME/zathura/zathurarc
$XDG_DATA_HOME/script-data/keybinds
$XDG_CONFIG_HOME/dmenu_web"
fzf_command="fzfp --ansi --layout=reverse -m --marker='󰄾' --pointer=' 󰶻'"
fzf_command="fzf --prompt ' Configs  ' \
--layout=reverse -m --height=100% --pointer=' ' \
--ellipsis= --scheme=path --algo=v2 --color='16' \
--preview-window='bottom,60%,border-top' --border=sharp \
--margin='5%,10%,5%,10%' --info=inline-right \
--ansi --preview='fuz-preview {}' \
--bind 'enter:become(nvim {})'"
selected=$(printf '%s\n' "${configs[@]}" | eval "$fzf_command")
if [ -n "$selected" ]; then
nvim "$selected"
fi
echo "$configs" | eval "$fzf_command"

View File

@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
# Check if dmenu is running
dunstctl close-all

View File

@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh
word=$(xclip -o -selection "clipboard")

View File

@ -1,11 +1,9 @@
#!/bin/bash
#!/bin/sh
json_url="https://raw.githubusercontent.com/ryanoasis/nerd-fonts/master/glyphnames.json"
local_file="$HOME/.local/share/script-data/chars/nerd-glyphs.json"
function needs_update() {
local local_date
local current_date
needs_update() {
local_date=$(stat -c %Y "$local_file" 2>/dev/null || echo 0)
current_date=$(date +%s)
[ "$((current_date - local_date))" -ge "$((14 * 24 * 3600))" ]

View File

@ -1,11 +0,0 @@
#!/bin/bash
file_path="$HOME/.cache/dwm_bar_color"
if [ -e "$file_path" ]; then
rm "$file_path"
echo "File '$file_path' deleted."
else
touch "$file_path"
echo "File '$file_path' created."
fi

View File

@ -3,24 +3,17 @@
# Populated by fuz-cache script through xprofile at startup
CACHE_DIR="/tmp/fuz_cache"
# Define color escape sequences
c_blue=''
c_gray=''
c_norm=''
h_padding=$(printf '%*s' 23 ' ')
h_gap=" ${c_gray}::"
h_padding=$(printf '%*s' 20 ' ')
h_gap=$(printf '%*s' 4 ' ')
# Define the header using the escape sequences
HEADER="${h_padding}\
${c_blue}Prefix${c_gray}:${c_norm}Alt${h_gap}\
${c_blue}1${c_gray}:${c_norm}All/Folders/Git${h_gap}\
${c_blue}2${c_gray}:${c_norm}Documents${h_gap}\
${c_blue}3${c_gray}:${c_norm}Images${h_gap}\
${c_blue}4${c_gray}:${c_norm}Videos"
 Prefix:Alt${h_gap}\
 1:All/Folders/Git${h_gap}\
 2:Documents${h_gap}\
 3:Images${h_gap}\
 4:Videos"
# --bind "alt-1:transform:[[ ! \$FZF_PROMPT =~ All ]] &&
# echo 'change-prompt( All  )+reload(cat $CACHE_DIR/all)' ||
# echo 'change-prompt( Folders  )+reload(cat $CACHE_DIR/folders)'" \
fzf_main_func() {
cat $CACHE_DIR/all | fzf --ansi --prompt " All  " \
--bind "alt-1:transform:(
@ -36,14 +29,8 @@ fzf_main_func() {
--preview "fuz-preview {}"
}
echo -ne '\e[3 q' # Use underline shape cursor on startup.
dwmc setlayoutex 2
selection=$(fzf_main_func)
if [ -n "$selection" ]; then
fuz-opener "$selection"
fi
# Reset layout to tile before exiting
dwmc setlayoutex 0

View File

@ -1,8 +1,5 @@
#!/usr/bin/env bash
# The purpose of this script is to demonstrate how to preview a file or an
# image in the preview window of fzf.
# Dependencies:
# - https://github.com/sharkdp/bat
# - https://github.com/hpjansson/chafa
@ -20,9 +17,6 @@ fi
file=${1/#\~\//$HOME/}
type=$(file --dereference --brief --mime-type -- "$file")
# Debug: Print the detected MIME type
# echo "Detected MIME type: $type"
# Array to hold temp files for cleanup
temp_files=()
@ -38,10 +32,21 @@ trap cleanup EXIT
# Function to preview text files
preview_text() {
bat --style="${BAT_STYLE:-numbers,header}" --color=always --pager=never -- "$file"
bat --style="${BAT_STYLE:-numbers,header}" --color=always --pager=never --line-range :19 -- "$file"
}
preview_json() {
jq -C . "$file"
}
preview_diff() {
delta < "$file"
}
preview_markdown() {
glow -s auto -w "$FZF_PREVIEW_COLUMNS" "$file"
}
# Function to preview images
preview_image() {
local image_file="$1"
dim=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}
@ -63,7 +68,6 @@ preview_image() {
fi
}
# Function to preview PDF files
preview_pdf() {
temp_image=$(mktemp /tmp/preview.XXXXXX)
temp_files+=("$temp_image" "${temp_image}.jpg")
@ -75,7 +79,6 @@ preview_pdf() {
fi
}
# Function to preview audio files
preview_audio() {
if command -v exiftool >/dev/null; then
exiftool -FileName -Title -Artist -Album -Genre -ChannelMode -AudioBitrate -FileSize -MIMEType -SampleRate -Duration "$file"
@ -85,7 +88,6 @@ preview_audio() {
fi
}
# Function to preview video files
preview_video() {
temp_image=$(mktemp /tmp/preview.XXXXXX.jpg)
temp_files+=("$temp_image")
@ -97,8 +99,7 @@ preview_video() {
fi
}
# Function to preview archives files
preview_zip() {
preview_archive() {
atool --list -- "$file"
}
@ -107,20 +108,32 @@ preview_dir() {
eza -Ga --group-directories-first --icons=always --color=always "$file"
}
# Dispatch based on MIME type
case "$type" in
inode/directory)
preview_dir "$file"
;;
text/plain)
preview_text "$file"
text/x-patch)
preview_diff "$file"
;;
text/x-diff)
preview_diff "$file"
;;
text/*)
preview_text "$file"
case "$file" in
*.md|*.markdown)
preview_markdown "$file"
;;
*)
preview_text "$file"
;;
esac
;;
image/*)
preview_image "$file"
;;
application/json)
preview_json "$file"
;;
application/pdf)
preview_pdf "$file"
;;
@ -130,8 +143,8 @@ audio/*)
video/*)
preview_video "$file"
;;
application/*zip)
preview_zip "$file"
application/zip|application/x-tar|application/gzip|application/x-bzip2|application/x-xz|application/x-rar|application/x-7z-compressed)
preview_archive "$file"
;;
*)
exiftool "$file"

View File

@ -14,6 +14,7 @@ fd_command="fd . \
--exclude .github \
--exclude *.o \
--exclude *.pyc \
--exclude node_modules \
--full-path \"$search_dir\""
fzf_command="fzf \

View File

@ -6,21 +6,21 @@ rm -f /tmp/rg-fzf-{r,f}
[ -d "$1" ] && SEARCH_DIR="$1" && shift || SEARCH_DIR="."
RG_PREFIX="rg --column --line-number --no-heading --follow --color=always --smart-case \
--glob '!/.ssh' --glob '!/.android' --glob '!/.gnupg'"
RG_PREFIX="rg --hidden --column --line-number --no-heading --follow --color=always --smart-case \
--glob '!/.ssh' --glob '!/.android' --glob '!/.gnupg' --glob '!node_modules'"
INITIAL_QUERY="${*:-}"
: | fzf --ansi --disabled --query "$INITIAL_QUERY" \
--bind "start:reload:$RG_PREFIX {q} $SEARCH_DIR" \
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} $SEARCH_DIR || true" \
--bind "ctrl-t:transform:[[ ! \$FZF_PROMPT =~ ripgrep ]] &&
--bind "ctrl-space:transform:[[ ! \$FZF_PROMPT =~ ripgrep ]] &&
echo \"rebind(change)+change-prompt(ripgrep  )+disable-search+transform-query:echo {q} > /tmp/rg-fzf-f; cat /tmp/rg-fzf-r\" ||
echo \"unbind(change)+change-prompt(fzf  )+enable-search+transform-query:echo {q} > /tmp/rg-fzf-r; cat /tmp/rg-fzf-f\"" \
--margin=5%,10%,5%,10% --height=100% --reverse --color=16 --info=inline-right \
--scrollbar=▐ --keep-right --info=hidden --border=none --ellipsis= \
--scrollbar=▐ --keep-right --border=none --ellipsis= \
--prompt 'ripgrep  ' \
--delimiter : \
--header 'CTRL-T: Switch between ripgrep/fzf' \
--header 'CTRL-Space: Switch between ripgrep/fzf' --header-first \
--preview 'bat --style=header,numbers --color=always {1} --highlight-line {2}' \
--preview-window 'bottom,60%,border-top,+{2}+3/3,~1' \
--bind 'enter:become(nvim {1} +{2})'