Compare commits

..

2 Commits

20 changed files with 2840 additions and 3278 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
helix/runtime helix/runtime
fish/fish_variables fish/fish_variables
# openbsd crash core dumps
*.core
*.log

View File

@ -12,7 +12,7 @@
# - /path/to/alacritty.yml # - /path/to/alacritty.yml
import: import:
- ~/.alacritty-colorscheme/themes/xterm.yaml - ~/.alacritty-colorscheme/themes/xterm.yaml
- ~/.alacrittyrc.yaml
# Any items in the `env` entry below will be added as # Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables # environment variables. Some entries may override variables
# set by alacritty itself. # set by alacritty itself.
@ -22,7 +22,7 @@ env:
# This value is used to set the `$TERM` environment variable for # This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will # each instance of Alacritty. If it is not present, alacritty will
# check the local terminfo database and use `alacritty` if it is # check the local terminfo database and use `alacritty` if it is
# available, otherwise `xterm-256color` is used. # available, otherwise `xterm-256color` i_configs used.
TERM: alacritty TERM: alacritty
#window: #window:
@ -175,7 +175,7 @@ env:
#use_thin_strokes: true #use_thin_strokes: true
# If `true`, bold text is drawn using the bright color variants. # If `true`, bold text is drawn using the bright color variants.
#draw_bold_text_with_bright_colors: false draw_bold_text_with_bright_colors: false
# Colors (Tomorrow Night) # Colors (Tomorrow Night)
#colors: #colors:
@ -409,7 +409,7 @@ env:
#thickness: 0.15 #thickness: 0.15
# Live config reload (changes require restart) # Live config reload (changes require restart)
#live_config_reload: true live_config_reload: true
# Shell # Shell
# #

File diff suppressed because it is too large Load Diff

View File

@ -10,8 +10,6 @@ SpellEnabled=True
EmojiEnabled=True EmojiEnabled=True
# Enable Chaizi # Enable Chaizi
ChaiziEnabled=True ChaiziEnabled=True
# Enable Characters in Unicode CJK Extension B
ExtBEnabled=True
# Enable Cloud Pinyin # Enable Cloud Pinyin
CloudPinyinEnabled=False CloudPinyinEnabled=False
# Cloud Pinyin Index # Cloud Pinyin Index
@ -26,16 +24,10 @@ PinyinInPreedit=False
Prediction=False Prediction=False
# Prediction Size # Prediction Size
PredictionSize=10 PredictionSize=10
# Action when switching input method
SwitchInputMethodBehavior="Commit current preedit"
# Select 2nd Candidate # Select 2nd Candidate
SecondCandidate= SecondCandidate=
# Select 3rd Candidate # Select 3rd Candidate
ThirdCandidate= ThirdCandidate=
# Use Keypad as Selection key
UseKeypadAsSelection=False
# Use BackSpace to cancel the selection
BackSpaceToUnselect=True
# Number of Sentences # Number of Sentences
Number of sentence=2 Number of sentence=2
# Prompt long word length when input length over (0 for disable) # Prompt long word length when input length over (0 for disable)
@ -88,7 +80,7 @@ FirstRun=False
[Fuzzy] [Fuzzy]
# ue -> ve # ue -> ve
VE_UE=True VE_UE=True
# Common Typo # gn -> ng
NG_GN=True NG_GN=True
# Inner Segment (xian -> xi'an) # Inner Segment (xian -> xi'an)
Inner=True Inner=True

View File

@ -3,5 +3,9 @@ set -x TERM "xterm-256color"
alias hc=herbstclient alias hc=herbstclient
set fish_greeting "" set fish_greeting ""
# Add local bin paths
fish_add_path $HOME/.cargo/bin
fish_add_path $HOME/.bin
# Local per-machine changes # Local per-machine changes
source $HOME/.fishrc source $HOME/.fishrc

View File

@ -1,34 +1,18 @@
#!/usr/bin/env #!/usr/bin/env
source (status dirname)/../include/parent.fish
function parent_dir
set -f trace (status stack-trace)
# By index:
# 1: in command substitution
# 2: parent.fish line
# 3: in function 'parent'
# 4: caller import line
# 5: in command substitution
# 6: caller "parent" invokation line
# 7: in function calling parent
# 8: jackpot! here's the parent of the caller
set -f parent_line $trace[8]
set -f parent_split (string split 'of file' $parent_line)
set -f parent (string trim $parent_split[2])
# qualify ~
set -f parent (string replace '~' "$HOME" $parent)
# Qualify the path to absolute and remove the filename
set -f parent_dir (realpath $parent)
set -f parent (string join '/' (string split '/' $parent_dir)[1..-2])
echo $parent
end
function import function import
set -f self_directory (parent_dir) set -f self_directory (parent_script_dir)
if set -q debug; if set -q debug;
echo "importing $argv.fish from [$self_directory]" echo "importing $argv.fish from [$self_directory]"
end end
if starts_with '@' "$argv"
set -f include_dir "$(status dirname)/../include/"
set -f import_path \
(string replace '@' "$include_dir" "$argv")
source "$import_path.fish"
return 0
end
if starts_with '/' "$argv" if starts_with '/' "$argv"
source "$argv.fish" source "$argv.fish"
return 0 return 0

27
fish/functions/log.fish Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/env fish
import @parent
# calls logger with a specific color
#
# examples:
#
# log "hello there"
# log -c magenta "im berry"
# log --color cc00cc "just like the blueberries"
function log
set -f log_name (parent_script)
# hlwm config particular
set -f cfg_color \
(hc attr settings.my_Color_$log_name 2> /dev/null)
argparse 'c/color=' -- $argv
if not set -q _flag_color; or test -n "$_flag_color"
if test -n "$cfg_color"
set -g _flag_color $cfg_color
else
set -g _flag_color green
end
end
echo -s "[ " (set_color $_flag_color) $log_name (set_color normal) " ]: $argv" 1>&2
end

51
fish/include/parent.fish Executable file
View File

@ -0,0 +1,51 @@
#!/usr/bin/env fish
# parent_script prints the parent script's filename
function parent_script
set -f trace (status stack-trace)
# By index:
# 1: in command substitution
# 2: parent.fish line
# 3: in function 'parent'
# 4: caller import line
# 5: in command substitution
# 6: caller "parent" invokation line
# 7: in function calling parent
# 8: jackpot! here's the parent of the caller
set -f parent_line $trace[8]
set -f parent_split (string split 'of file' $parent_line)
set -f parent (string trim $parent_split[2])
# Clean up the parent a lil bit
set -f parent (realpath (string replace '~' "$HOME" $parent))
set -f parent_parts (string split '/' $parent)
set -f parent (string join '/' $parent_parts[-1])
# remove .fish suffix
set -f parent (string replace '.fish' '' $parent)
echo $parent
end
function parent_script_dir
set -f trace (status stack-trace)
# By index:
# 1: in command substitution
# 2: parent.fish line
# 3: in function 'parent'
# 4: caller import line
# 5: in command substitution
# 6: caller "parent" invokation line
# 7: in function calling parent
# 8: jackpot! here's the parent of the caller
set -f parent_line $trace[8]
set -f parent_split (string split 'of file' $parent_line)
set -f parent (string trim $parent_split[2])
# qualify ~
set -f parent (string replace '~' "$HOME" $parent)
# Qualify the path to absolute and remove the filename
set -f parent_dir (realpath $parent)
set -f parent (string join '/' (string split '/' $parent_dir)[1..-2])
echo $parent
end

View File

@ -6,4 +6,4 @@ auto-completion = true
#left = ["mode", "spinner"] #left = ["mode", "spinner"]
[editor.lsp] [editor.lsp]
display-messages = true # display-messages = true

View File

@ -1,9 +0,0 @@
#!/usr/bin/env fish
set -g FISH_CMDS_PATH $HOME/.config/herbstluftwm/fish_cmds
# cmd_string returns the shell command to invoke
# the fish_cmds file title given to it as an argument
function cmd_string
set -f FISH_PATH (status fish-path)
printf "$FISH_PATH\n$FISH_CMDS_PATH/$argv.fish"
end

View File

@ -1,13 +0,0 @@
#!/usr/bin/env fish
function hlwm_active
echo (herbstclient attr theme.active.color)
end
function hlwm_normal
echo (herbstclient attr theme.normal.color)
end
function hlwm_text
echo (herbstclient attr theme.normal.title_color)
end

View File

@ -0,0 +1,48 @@
#!/usr/bin/env fish
import @parent
alias hc=herbstclient
function new_config
argparse -i 'n/name=' 'v/value=' 't/type=' -- $argv
set_default _flag_type 'string'
if test -z "$_flag_name"; or test -z "$_flag_value"
log -c 'red' "name and value must be set"
return 1
end
set -f cfg_name (printf 'settings.my_%s' $_flag_name)
hc get_attr settings.my_$_flag_name &> /dev/null
if test $status -eq 0
hc set_attr "settings.my_$_flag_name" \
$_flag_value #&> /dev/null
else
hc new_attr "$_flag_type" \
"$cfg_name" \
"$_flag_value" #&> /dev/null
end
end
function set_config
argparse -i 'n/name=' 'v/value=' -- $argv
if test -z "$_flag_name"; or test -z "$_flag_value";
log -c 'red' "name and value must be set"
return 1
end
set -f cfg_name (printf 'settings.my_%s' $_flag_name)
hc set_attr $cfg_name $_flag_value
end
function get_config
set -f cfg_name (printf 'settings.my_%s' "$argv")
hc get_attr $cfg_name
end
function set_log_color
set -f parent (parent_script)
new_config \
-t string \
-n "$(printf 'Color_%s' "$parent")" \
-v "$argv"
end

View File

@ -1,18 +1,21 @@
#!/usr/bin/env #!/usr/bin/env
import notify import notify
import log import config
alias hc=herbstclient alias hc=herbstclient
set -g tag_color "ff99cc" set_log_color "ff99cc"
# group_active_reset resets the active group (unset) # group_active_reset resets the active group to 1
function group_active_reset function group_active_reset
set -q hlwm_group_active new_config \
-t uint \
-n ActiveGroup \
-v 1
end end
function group_switch function group_switch
set -f current $hlwm_group_active set -f current (get_config ActiveGroup)
set -f arg $argv[1] set -f arg $argv[1]
if not set -q arg if not set -q arg
@ -26,33 +29,36 @@ function group_switch
# is a number # is a number
group_index $arg group_index $arg
else else
log -c $tag_color "invalid group index [$arg], use '+', '-', or a real integer" log "invalid group index [$arg], use '+', '-', or a real integer"
return 1 return 1
end end
# update the tag it should now be on, if it switched # update the tag it should now be on, if it switched
if test $hlwm_group_active -ne $current if test (get_config ActiveGroup) -ne $current
update_tag $current update_tag $current
end end
group_set_keybinds group_set_keybinds
notify "Group $hlwm_group_active" set -f active (get_config ActiveGroup)
log -c $tag_color "group $current -> $hlwm_group_active" notify "Group $active"
log "group $current -> $active"
end end
# move_to_group moves the focused window to the relative tag on # move_to_group moves the focused window to the
# a given group # relative tag on a given group
function move_to_group function move_to_group
set -f move_to "$argv" set -f move_to "$argv"
if test "$move_to" = "$hlwm_group_active" set -f active (get_config ActiveGroup)
log -c $tag_color "ignoring move as it's already in the active group" if test "$move_to" = "$active"
log "ignoring move as it's already in the active group"
return 0 return 0
else if test $move_to -lt 1 -o $move_to -gt $hlwm_group_count else if test $move_to -lt 1; or \
log -c $tag_color "invalid group index [$move_to]:" \ $move_to -gt (get_config GroupCount)
"out of range [1:$hlwm_group_count]" log "invalid group index [$move_to]:" \
"out of range [1:$(get_config GroupCount)]"
return 1 return 1
end end
set -f new_tag (translate_tag $hlwm_group_active $move_to) set -f new_tag (translate_tag $active $move_to)
log -c $tag_color "moving window to group [$move_to]" \ log "moving window to group [$move_to]" \
"tag -> $new_tag" "tag -> $new_tag"
end end
@ -64,66 +70,83 @@ function translate_tag
set -f current_actual (hc attr tags.focus.index) set -f current_actual (hc attr tags.focus.index)
set -f tl_from $argv[1] set -f tl_from $argv[1]
set -f tl_to $argv[2] set -f tl_to $argv[2]
set -f offset_from (math (math $tl_from - 1) x $hlwm_tags_per_group) set -f offset_from \
set -f offset_to (math (math $tl_to - 1) x $hlwm_tags_per_group) (math \
set -f relative_tag_from (math $current_actual - $offset_from) (math $tl_from - 1) x \
log -c $tag_color \ (get_config TagsPerGroup))
"calculated relative tag to group [$tl_from] to be [$relative_tag_from]" set -f offset_to \
set -f actual_tag_to (math $relative_tag_from + $offset_to) (math \
log -c $tag_color \ (math $tl_to - 1) x \
"relative tag [$relative_tag_from] translated to group [$tl_to]" \ (get_config TagsPerGroup))
set -f relative_tag_from \
(math $current_actual - $offset_from)
log \
"calculated relative tag to" \
"group [$tl_from] to be" \
"[$relative_tag_from]"
set -f actual_tag_to \
(math $relative_tag_from + $offset_to)
log \
"relative tag" \
"[$relative_tag_from]" \
"translated to group [$tl_to]"\
"becomes actual tag [$actual_tag_to]" "becomes actual tag [$actual_tag_to]"
echo $actual_tag_to echo $actual_tag_to
end end
function update_tag function update_tag
set -f new_tag (translate_tag $argv $hlwm_group_active) set -f new_tag (translate_tag $argv \
log -c $tag_color "moving frame focus to tag: [$new_tag]" $(get_config ActiveGroup))
log "moving frame focus to tag: [$new_tag]"
hc use_index $new_tag hc use_index $new_tag
end end
function group_down function group_down
if not set -q hlwm_group_active set -f active_grp (get_config ActiveGroup)
if not set -q active_grp; or \
test $active_grp -eq 1
# Treat unset == 1, so move back to the last one # Treat unset == 1, so move back to the last one
set -U hlwm_group_active $hlwm_group_count set_config -n ActiveGroup -v (get_config GroupCount)
else if test $hlwm_group_active -eq 1
set -U hlwm_group_active $hlwm_group_count
else else
set -U hlwm_group_active (math $hlwm_group_active - 1) set_config -n ActiveGroup -v (math $active_grp - 1)
end
end
function group_up
set -f active_grp (get_config ActiveGroup)
if test $active_grp -le 1
set_config -n ActiveGroup -v 2
else if test $active_grp -eq (get_config GroupCount)
set_config -n ActiveGroup -v 1
else
set_config -n ActiveGroup \
-v (math $active_grp + 1)
end end
end end
function group_index function group_index
if test $argv -gt $hlwm_group_count if test $argv -gt (get_config GroupCount)
set -f $argv $hlwm_group_count set -f $argv (get_config GroupCount)
else if test $argv -lt 1 else if test $argv -lt 1
set -f $argv 1 set -f $argv 1
end end
set -U hlwm_group_active $argv set_config -n ActiveGroup -v $argv
end
function group_up
if not set -q hlwm_group_active
set -U hlwm_group_active 2
else if test $hlwm_group_active -eq $hlwm_group_count
set -U hlwm_group_active 1
else
set -U hlwm_group_active (math $hlwm_group_active + 1)
end
end end
# group_set_keybinds sets the keybinds to the given tab group # group_set_keybinds sets the keybinds to the given tab group
function group_set_keybinds function group_set_keybinds
set_default hlwm_mod Mod4 set_default hlwm_mod (get_config ModKey)
log -c $tag_color "setting keybinds for group: $hlwm_group_active" set -f grp (get_config ActiveGroup)
if not set -q hlwm_group_active; set -f tags_per (get_config TagsPerGroup)
set -U hlwm_group_active 1 log "setting keybinds for group: $grp"
end set -l offset (math \
set -l offset (math (math $hlwm_group_active-1) x $hlwm_tags_per_group) (math $grp-1) x $tags_per)
for tag in (seq $hlwm_tags_per_group) for tag in (seq $tags_per)
set -l actual_tag (math $tag + $offset) set -l actual_tag (math $tag + $offset)
hc keybind $hlwm_mod-$tag use_index (math $actual_tag-1) hc keybind $hlwm_mod-$tag use_index \
hc keybind $hlwm_mod-Shift-$tag move_index (math $actual_tag-1) (math $actual_tag - 1)
hc keybind $hlwm_mod-Shift-$tag move_index \
(math $actual_tag - 1)
end end
end end

View File

@ -1,19 +0,0 @@
#!/usr/bin/env fish
import parent
# calls logger with a specific color
#
# examples:
#
# log "hello there"
# log -c magenta "im berry"
# log --color cc00cc "just like the blueberries"
function log
set -f log_name (parent)
argparse 'c/color=' -- $argv
if not set -q _flag_color;
set -g _flag_color green
end
echo -s "[ " (set_color $_flag_color) $log_name (set_color normal) " ]: $argv" 1>&2
end

View File

@ -1,24 +1,29 @@
#!/usr/bin/env fish #!/usr/bin/env fish
import colors import config
import log
set_default notify_fg (hlwm_text)
set_default notify_bg (hlwm_normal)
set_default notify_font $hlwm_font
set_default notify_padding 30
function notify function notify
argparse -i 'secs=!_validate_int --min 1' -- $argv argparse -i 'fg=' \
'bg=' \
'f/font=' \
'p/padding=' \
'secs=!_validate_int --min 1' \
-- $argv
set_default _flag_fg (get_config NotifyTextColor)
set_default _flag_bg (get_config NotifyBgColor)
set_default _flag_font (get_config Font)
set_default _flag_padding 30
set_default _flag_secs 1 set_default _flag_secs 1
set -f text_width (textwidth "$notify_font" "$argv")
log "using font '$_flag_font'"
set -f text_width (textwidth "$_flag_font" "$argv")
echo "$argv" | \ echo "$argv" | \
dzen2 \ dzen2 \
-p $_flag_secs \ -p $_flag_secs \
-fg $notify_fg \ -fg $_flag_fg \
-bg $notify_bg \ -bg $_flag_bg \
-fn $notify_font \ -fn $_flag_font \
-ta 'c' \ -ta 'c' \
-w (math $text_width + $notify_padding) \ -w (math $text_width + $_flag_padding) \
-h 16 -h 16
end end

View File

@ -1,27 +0,0 @@
#!/usr/bin/env fish
# parent prints the parent script's filename
function parent
set -f trace (status stack-trace)
# By index:
# 1: in command substitution
# 2: parent.fish line
# 3: in function 'parent'
# 4: caller import line
# 5: in command substitution
# 6: caller "parent" invokation line
# 7: in function calling parent
# 8: jackpot! here's the parent of the caller
set -f parent_line $trace[8]
set -f parent_split (string split 'of file' $parent_line)
set -f parent (string trim $parent_split[2])
# Clean up the parent a lil bit
set -f parent (realpath (string replace '~' "$HOME" $parent))
set -f parent_parts (string split '/' $parent)
set -f parent (string join '/' $parent_parts[-1])
# remove .fish suffix
set -f parent (string replace '.fish' '' $parent)
echo $parent
end

View File

@ -0,0 +1,19 @@
#!/usr/bin/env fish
function remove_default
set -f default_tag ( \
hc get_attr tags.by-name.default.index \
&> /dev/null \
)
if test -z "$default_tag"
return 0
end
if test \
"$(hc get_attr tags.focus.index)" = \
"$default_tag"
# switch from default tag
hc use_index 1
end
hc merge_tag "default"
log "removed"
end

View File

@ -1,6 +1,4 @@
#!/usr/bin/env fish #!/usr/bin/env fish
import log
alias hc=herbstclient alias hc=herbstclient
function restart_svcs function restart_svcs

View File

@ -2,6 +2,8 @@
import fish_functions/notify import fish_functions/notify
import fish_functions/restart_svcs import fish_functions/restart_svcs
import fish_functions/group import fish_functions/group
import fish_functions/config
import fish_functions/remove_default
set -g THIS_PATH (pwd) set -g THIS_PATH (pwd)
log "starting in $THIS_PATH" log "starting in $THIS_PATH"
@ -10,6 +12,7 @@ alias hc=herbstclient
# default font if not set # default font if not set
set_default hlwm_font "-*-fixed-medium-*-*-*-12-*-*-*-*-*-*-*" set_default hlwm_font "-*-fixed-medium-*-*-*-12-*-*-*-*-*-*-*"
new_config -n Font -v "$hlwm_font"
hc emit_hook reload hc emit_hook reload
if command -sq "xsetroot"; if command -sq "xsetroot";
@ -22,18 +25,21 @@ group_active_reset
set -g Mod Mod4 set -g Mod Mod4
set -g AltMod Mod1 set -g AltMod Mod1
set -u hlwm_mod $Mod new_config ModKey $Mod
set -U hlwm_mod $Mod
function key function key
log "Registering $Mod-$argv[1] to [$argv[2..]]" log "Registering $Mod-$argv[1] to [$argv[2..]]"
hc keybind $Mod-$argv[1] $argv[2..] hc keybind $Mod-$argv[1] $argv[2..]
end end
set_default hlwm_terminal_spawn_key "Home"
hc keybind $Mod-Shift-r reload hc keybind $Mod-Shift-r reload
hc keybind $Mod-Shift-c close hc keybind $Mod-Shift-c close
hc keybind $Mod-s spawn "flameshot" gui hc keybind $Mod-s spawn "flameshot" gui
hc keybind $Mod-Return spawn "dmenu_run" hc keybind $Mod-Return spawn "dmenu_run"
hc keybind $Mod-Home spawn "alacritty" hc keybind $Mod-$hlwm_terminal_spawn_key spawn "alacritty"
# basic movement in tiling and floating mode # basic movement in tiling and floating mode
# focusing clients # focusing clients
@ -62,8 +68,15 @@ hc keybind $Mod-Control-Down resize down +$resize_step
hc keybind $Mod-Control-Up resize up +$resize_step hc keybind $Mod-Control-Up resize up +$resize_step
hc keybind $Mod-Control-Right resize right +$resize_step hc keybind $Mod-Control-Right resize right +$resize_step
set_default -u hlwm_tags_per_group 5 set_default hlwm_tags_per_group 5
set_default -u hlwm_group_count 3 set_default hlwm_group_count 3
new_config -n GroupCount \
-v $hlwm_group_count \
-t uint
new_config -n TagsPerGroup \
-v $hlwm_tags_per_group \
-t uint
log "registering $hlwm_group_count groups, with $hlwm_tags_per_group tags per" log "registering $hlwm_group_count groups, with $hlwm_tags_per_group tags per"
set -l tag_indexes (seq $hlwm_tags_per_group) set -l tag_indexes (seq $hlwm_tags_per_group)
@ -75,16 +88,8 @@ for group_num in (seq $hlwm_group_count)
end end
end end
# Remove the default tag, if present (switching to the first tag) # Remove the default tag
if set -l default_tag (hc get_attr tags.by-name.default.index) remove_default
set -l focused_tag (hc get_attr tags.focus.index)
if test $focused_tag -eq $default_tag
hc use_index 1
end
hc merge_tag "default"
log "removed default tag from index [$default_tag]"
end
group_set_keybinds group_set_keybinds
# focus # focus
@ -162,6 +167,11 @@ hct urgent.inner_color $URGENT
hct title_color white hct title_color white
hct normal.title_color '#898989' hct normal.title_color '#898989'
new_config -n NotifyTextColor \
-v (hc attr theme.normal.title_color)
new_config -n NotifyBgColor -v $NORMAL
for state in active urgent normal for state in active urgent normal
hc substitute C theme.$state.inner_color \ hc substitute C theme.$state.inner_color \
attr theme.$state.outer_color C attr theme.$state.outer_color C
@ -206,7 +216,6 @@ end
log "Registering custom command binds" log "Registering custom command binds"
keybind_fn i "toggle_idle_screen" keybind_fn i "toggle_idle_screen"
keybind_fn --direct="switch_group" "grave" "+" # backtick keybind_fn --direct="switch_group" "grave" "+" # backtick
keybind_fn --direct="switch_group" "Tab-grave" "-"
for group_index in (seq $hlwm_group_count) for group_index in (seq $hlwm_group_count)
keybind_fn --direct="switch_group" "F$group_index" "$group_index" keybind_fn --direct="switch_group" "F$group_index" "$group_index"
end end

View File

@ -1,3 +0,0 @@
# hlwm conf todo
- [ ] use hlwm attrs (new_attr in herbstluftwm(1)) rather than fish env