First Commit

This commit is contained in:
ant 2024-02-27 16:03:12 +01:00
commit cae9d57360
22 changed files with 1957 additions and 0 deletions

35
bin/dark.fish Executable file
View file

@ -0,0 +1,35 @@
if test -e $XDG_STATE_HOME/darkmode
rm $XDG_STATE_HOME/darkmode
set LIGHT 1
else
echo > $XDG_STATE_HOME/darkmode
set LIGHT 0
end
if test $LIGHT = 1;
notify-send "Light mode"
rm -f ~/.config/kitty/colors.conf
ln -rs ~/.config/kitty/light.conf ~/.config/kitty/colors.conf
kill -SIGUSR1 $(pgrep kitty) # reload kitty config
rm -f ~/.local/share/bg/*
ln -rs ~/.local/share/bg-light.* ~/.local/share/bg/
hyprctl reload
rm -f ~/.config/rofi/colors-current.rasi
ln -rs ~/.config/rofi/colors-light.rasi ~/.config/rofi/colors-current.rasi
else
notify-send "Dark mode"
rm -f ~/.config/kitty/colors.conf
ln -rs ~/.config/kitty/dark.conf ~/.config/kitty/colors.conf
kill -SIGUSR1 $(pgrep kitty) # reload kitty config
rm -f ~/.local/share/bg/*
ln -rs ~/.local/share/bg-dark.* ~/.local/share/bg/
hyprctl reload
rm -f ~/.config/rofi/colors-current.rasi
ln -rs ~/.config/rofi/colors-dark.rasi ~/.config/rofi/colors-current.rasi
end

42
bin/dark.nix Executable file
View file

@ -0,0 +1,42 @@
{ pkgs, ... } :
pkgs.writers.writeFish "dark" ''
if test -e $XDG_STATE_HOME/darkmode
rm $XDG_STATE_HOME/darkmode
set LIGHT 1
else
echo > $XDG_STATE_HOME/darkmode
set LIGHT 0
end
if test $LIGHT = 1;
${pkgs.libnotify}/bin/notify-send "Light mode"
rm -f ~/.config/kitty/colors.conf
ln -rs ~/.config/kitty/light.conf ~/.config/kitty/colors.conf
kill -SIGUSR1 $(pgrep kitty) # reload kitty config
rm -f ~/.local/share/bg/*
ln -rs ~/.local/share/bg-light.* ~/.local/share/bg/
${pkgs.hyprland}/bin/hyprctl reload
rm -f ~/.config/rofi/colors-current.rasi
ln -rs ~/.config/rofi/colors-light.rasi ~/.config/rofi/colors-current.rasi
${pkgs.dconf}/bin/dconf write /org/gnome/desktop/interface/color-scheme "'prefer-light'"
else
${pkgs.libnotify}/bin/notify-send "Dark mode"
rm -f ~/.config/kitty/colors.conf
ln -rs ~/.config/kitty/dark.conf ~/.config/kitty/colors.conf
kill -SIGUSR1 $(pgrep kitty) # reload kitty config
rm -f ~/.local/share/bg/*
ln -rs ~/.local/share/bg-dark.* ~/.local/share/bg/
${pkgs.hyprland}/bin/hyprctl reload
rm -f ~/.config/rofi/colors-current.rasi
ln -rs ~/.config/rofi/colors-dark.rasi ~/.config/rofi/colors-current.rasi
${pkgs.dconf}/bin/dconf write /org/gnome/desktop/interface/color-scheme "'prefer-dark'"
end
''

3
bin/ocrzone Executable file
View file

@ -0,0 +1,3 @@
f=$(mktemp --suffix .png)
${pkgs.sway-contrib.grimshot}/bin/grimshot save area $f
${pkgs.tesseract}/bin/tesseract -l fra "$f" - | wl-copy

1
bin/runmenu Executable file
View file

@ -0,0 +1 @@
${pkgs.rofi-wayland}/bin/rofi -matching normal -sort -show run

39
bin/screenshot.nix Executable file
View file

@ -0,0 +1,39 @@
{ pkgs, ... }:
pkgs.writers.writePython3 "screenshot" { flakeIgnore = [ "E501" ];} ''
import subprocess
import re
options = """\
a selected area (copy)
current window (copy)
full screen (copy)
a selected area
current window
full screen
"""
cmd = '${pkgs.rofi-wayland}/bin/rofi -dmenu -location 2 -l 6 -i -p "Screenshot which area?"'
result = subprocess.run(cmd,
input=options,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
text=True)
if result.returncode != 0:
exit(1)
choice = result.stdout.strip()
cmd = "${pkgs.pkgs.sway-contrib.grimshot}/bin/grimshot "
cmd += "copy " if re.match(".*(copy)", choice) else "save "
for k, v in {"a selected area.*": "area ",
"current window.*": "active ",
"current screen.*": "output ",
"all screens.*": "screen "}.items():
if re.match(k, choice):
cmd += v
subprocess.call(cmd,
shell=True)
''

6
bin/window_dir Executable file
View file

@ -0,0 +1,6 @@
#!/bin/sh
PID=$(hyprctl activewindow | grep pid | cut -d' ' -f 2)
PID=$(echo $(ps --ppid $PID -o pid | tail -n1))
cwd=$(readlink /proc/"$PID"/cwd)
echo "$cwd"

29
bin/wl Executable file
View file

@ -0,0 +1,29 @@
#!/bin/sh
cd ~
# Log WLR errors and logs to the hyprland log. Recommended
export HYPRLAND_LOG_WLR=1
# Tell XWayland to use a cursor theme
export XCURSOR_THEME=Bibata-Modern-Classic
# Set a cursor size
export XCURSOR_SIZE=24
# Example IME Support: fcitx
# export GTK_IM_MODULE=fcitx
# export QT_IM_MODULE=fcitx
# export XMODIFIERS=@im=fcitx
# export SDL_IM_MODULE=fcitx
# export GLFW_IM_MODULE=ibus
export WLR_NO_HARDWARE_CURSORS=1
if lsmod | grep nvidia; then
export LIBVA_DRIVER_NAME=nvidia
export XDG_SESSION_TYPE=wayland
# export GBM_BACKEND=nvidia-drm
export __GLX_VENDOR_LIBRARY_NAME=nvidia
fi
exec Hyprland

17
dotfiles/keepmenu.ini Normal file
View file

@ -0,0 +1,17 @@
[dmenu]
dmenu_command = rofi -i
[dmenu_passphrase]
nf = #222222
nb = #222222
rofi_obscure = True
[database]
database_1 = ~/.local/passdb.kdbx
keyfile_1 =
pw_cache_period_min = 360
autotype_default = {USERNAME}{TAB}{PASSWORD}
editor = nvim
terminal = alacritty
type_library = wtype

21
dotfiles/kitty/dark.conf Normal file
View file

@ -0,0 +1,21 @@
background #0d0f18
foreground #fffaf3
cursor #ff0017
selection_background #002a3a
color0 #222222
color8 #444444
color1 #ff000f
color9 #ff273f
color2 #8ce00a
color10 #abe05a
color3 #ffb900
color11 #ffd141
color4 #008df8
color12 #0092ff
color5 #6c43a5
color13 #9a5feb
color6 #00d7eb
color14 #67ffef
color7 #ffffff
color15 #ffffff
selection_foreground #0d0f18

21
dotfiles/kitty/light.conf Normal file
View file

@ -0,0 +1,21 @@
background #f8f8f8
foreground #2a2b33
cursor #bbbbbb
selection_background #e5e5e6
color0 #000000
color8 #000000
color1 #de3d35
color9 #de3d35
color2 #3e953a
color10 #3e953a
color3 #d2b67b
color11 #d2b67b
color4 #2f5af3
color12 #2f5af3
color5 #950095
color13 #a00095
color6 #3e953a
color14 #3e953a
color7 #bbbbbb
color15 #ffffff
selection_foreground #2a2b33

View file

@ -0,0 +1,8 @@
* {
accent: #53BDFA;
warning: #EA6C73;
bg: #0A0E14;
fg: #B3B1AD;
alternate: #01060E;
transparent: #00000000;
}

View file

@ -0,0 +1,8 @@
* {
accent: #4196df;
warning: #FF7383;
bg: #F8F9FA;
fg: #26292f;
alternate: #eeeeee;
transparent: #00000000;
}

View file

@ -0,0 +1 @@
@theme "theme.rasi"

122
dotfiles/rofi/theme.rasi Normal file
View file

@ -0,0 +1,122 @@
/**
* A floating box version of the paper theme.
*
* User: Qball
* Copyright: Dave Davenport
*/
@import "colors-current.rasi"
* {
spacing: 0;
background-color: @transparent;
border-color: @fg;
anchor: north;
location: center;
text-color: @fg;
}
window {
transparency: "real";
background-color: @transparent;
border: 0;
padding: 0% 0% 1em 0%;
x-offset: 0;
y-offset: -10%;
}
mainbox {
padding: 0px;
border: 0;
spacing: 1%;
}
inputbar {
spacing: 0;
border: 1px;
padding: 0.4em 0.2em;
background-color: @bg;
index: 0;
children: [ prompt,textbox-prompt-colon,entry,case-indicator ];
}
textbox-prompt-colon {
expand: false;
str: ":";
margin: 0px 0.3em 0em 0em ;
}
prompt {
text-color: inherit;
}
entry {
text-color: inherit;
}
listview {
border: 1px;
reverse: false;
columns: 1;
background-color: @bg;
/* fixed-height: false; */
/* dynamic: true; */
}
element {
border: 0;
padding: 2px;
highlight: bold ;
}
element-text {
background-color: inherit;
text-color: inherit;
}
element {
text-color: @fg;
background-color: @transparent;
}
element normal.urgent {
text-color: @warning;
}
element selected {
text-color: @bg;
background-color: @accent;
}
element selected.urgent {
text-color: @warning;
}
element alternate {
background-color: @alternate;
}
element alternate.urgent {
text-color: @warning;
}
scrollbar {
border: 0;
padding: 0;
}
mode-switcher {
border: 1px;
padding: 0.4em 1em;
background-color: @alternate;
index: 10;
}
message {
border: 1px;
padding: 1em;
background-color: @bg;
text-color: @fg;
}
textbox normal {
text-color: @fg;
padding: 0;
border: 0;
}
error-message {
border: 1px;
padding: 0.4em;
background-color: #FF8888;
text-color: @fg;
}

216
dotfiles/waybar.css Normal file
View file

@ -0,0 +1,216 @@
* {
border: none;
border-radius: 0;
background: rgba(0, 0, 0, 0);
/* font-family: "CartographCF italic"; */
font-family: "Material Design Icons", Roboto;
/* font-family: "Roboto"; */
font-weight: bold;
font-size: 14px;
min-height: 0;
}
tooltip {
background: #000000;
/* border-radius: 10px; */
border-width: 2px;
border-style: solid;
border-color: #222222;
}
#custom-language,
#idle_inhibitor,
#custom-updates,
#bluetooth,
#custom-caffeine,
#custom-weather,
#custom-nvidia-load,
#custom-nvidia-mem,
#window,
#clock,
#battery,
#pulseaudio,
#network,
#workspaces,
#tray,
#disk,
#memory,
#temperature,
#cpu,
#mpris,
#submap,
#workspaces,
#backlight {
background: rgba(0, 0, 0, .6);
color: #ffffff;
padding: 0px 10px;
/* margin-top: 0px; */
/* margin-bottom: 0px; */
/* margin-right: 3px; */
/* margin-left: 3px; */
/* border: 1px solid #000000; */
border-radius: 14px;
margin: 0px 4px 0px 4px;
}
#workspaces {
padding: 0;
margin-left: 0;
margin-right: 0;
border-radius: 0;
}
#workspaces button {
padding: 4px;
color: #aaaaaa;
border-radius: 16px
}
#workspaces button.active {
color: #ffffff;
background: #0f0f0f;
}
#workspaces button.focused {
/* color: #a6adc8; */
background: #eba0ac;
/* border-radius: 10px; */
}
#workspaces button.urgent {
/* color: #11111b; */
background: #a6e3a1;
/* border-radius: 10px; */
}
#workspaces button:hover {
background: #11111b;
/* color: #cdd6f4; */
/* border-radius: 10px; */
}
#pulseaudio.speaker {
/* color: #89b4fa; */
/* border-radius: 10px 0 0 10px; */
margin-left: 0;
margin-right: 0;
border-radius: 0;
}
#pulseaudio.microphone {
/* color: #cba6f7; */
margin-left: 0;
margin-right: 0;
border-radius: 0;
}
#idle_inhibitor {
margin-left: 0;
margin-right: 0;
border-radius: 0;
}
#backlight {
border-radius: 0 14px 14px 0;
margin-left: 0;
}
#submap {
background: #000000;
border: 1px solid #ffffff;
color: #ffffff;
}
/* #mpris { */
/* border-radius: 10px; */
/* font-family: "CartographCF italic"; */
/* } */
#tray {
border-radius: 0;
margin-left: 0;
margin-right: 0;
}
#network {
border-radius: 10px;
border-radius: 14px 0 0 14px;
margin-right: 0;
}
#disk {
border-radius: 0;
margin-right: 0;
margin-left: 0;
}
#cpu {
border-radius: 0;
margin-left: 0;
margin-right: 0;
}
#temperature {
/* color: #f9afdb; */
border-radius: 0;
margin-right: 0;
margin-left: 0;
}
#memory {
/* border-radius: 0 10px 10px 0; */
margin-left: 0;
margin-right: 0;
border-radius: 0;
}
#memory.low {
/* color: #f85754; */
}
#battery {
border-radius: 0;
margin-left: 0;
margin-right: 0;
}
#clock {
margin-left: 0;
margin-right: 0;
border-radius: 0;
}
/* #custom-gpu { */
/* color: #f5c2e7; */
/* border-radius: 10px; */
/* } */
#window {
color: #ffffff;
text-shadow: 1px 0 #000, -1px 0 #000, 0 1px #000, 0 -1px #000,
1px 1px #000, -1px -1px #000, 1px -1px #000, -1px 1px #000;
background: rgba(0, 0, 0, 0);
border: 0
}
#bluetooth {
border-radius: 0;
margin-left: 0;
margin-right: 0;
}
#custom-weather {
/* border-radius: 10px 0px 0px 10px; */
margin-right: 0;
}
#custom-nvidia-load {
/* border-radius: 10px 0 0 10px; */
margin-right: 0;
/* color: #afb8f9; */
}
#custom-nvidia-mem {
/* border-radius: 0 10px 10px 0; */
margin-left: 0;
/* color: #aff9b2; */
}

234
dotfiles/waybar.jsonc Normal file
View file

@ -0,0 +1,234 @@
{
"layer": "top",
"position": "bottom",
"exclusive": true,
"passtrough": false,
"gtk-layer-shell": true,
"height": 0,
"on-scroll-up": "hyprctl dispatch workspace e+1",
"on-scroll-down": "hyprctl dispatch workspace e-1",
"modules-left": [
"hyprland/workspaces",
"pulseaudio#speaker",
"pulseaudio#microphone",
"idle_inhibitor",
"bluetooth",
"backlight",
"mpris",
"hyprland/submap",
"hyprland/window"
],
"modules-center": [],
"modules-right": [
// "custom/updates",
// "custom/nvidia-load",
// "custom/nvidia-mem",
"disk#2",
"network",
"disk",
"cpu",
"temperature",
"memory",
"battery",
// "custom/weather",
"tray",
"clock",
],
"backlight": {
"device": "intel_backlight",
"format": "{icon}",
"on-click": "light -S 100",
"on-click-right": "light -S 1",
"tooltip-format": "{percent}%",
"format-icons": ["󰛩", "󱩎", "󱩏", "󱩐", "󱩑", "󱩒", "󱩓", "󱩔", "󱩕", "󱩖", "󰛨"]
},
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "󰈈",
"deactivated": "󰈉"
}
},
"bluetooth": {
"format": "󰂯",
"format-disabled": "󰂲",
"on-click": "rfkill toggle bluetooth",
"on-click-right": "alacritty --class floating -e bluetuith",
"tooltip-format": "{}"
},
"mpris": {
"format": "{player_icon} {title}",
"format-paused": "{status_icon} <i>{title}</i>",
"player-icons": {
"default": "󰐊",
"mpv": "󰐍",
"spotify": "󰓇"
},
"status-icons": {
"paused": "󰏤"
},
// "ignored-players": ["mpv"]
},
"disk": {
"interval": 30,
"format": "󰋊 {free}",
"path": "/",
"on-click": "alacritty --class floating -e ncdu -x /"
},
"disk#2": {
"interval": 30,
"format": "{path} {free}",
"path": "/home/ant/storage",
"on-click": "alacritty --class floating -e ncdu -x /home/ant/storage"
},
"memory": {
"interval": 1,
"format": "󰧑 {percentage}%",
"tooltip-format": "{used:0.1f}G/{total:0.1f}G",
"states": { "low": 70 },
"on-click": "notify-send \"$(printf \"%-20s %10s\\n\" \"COMMAND\" \"MEMORY USAGE\"; ps axo comm,rss | awk '{mem[$1]+=$2} END {for (cmd in mem) printf \"%-20s %5.2f MiB\\n\", cmd, mem[cmd]/1024}' | sort -k2nr | head -n10)\""
},
"network": {
"interval": 1,
"format": "󰌙",
"format-disconnected": "󰌙",
"format-linked": "󰛵",
"format-ethernet": "󰓢 {bandwidthDownBytes} {bandwidthUpBytes}",
"format-wifi": "󰖩 {bandwidthDownBytes} {bandwidthUpBytes}",
"on-click": "wifi-toggle",
"on-right-click": "$TERMINAL --class floating -e nmtui",
"tooltip-format-ethernet": "{ipaddr}",
"tooltip-format-wifi": "{ipaddr}\n{essid}\n{signalStrength}"
},
"hyprland/window": {
"format": "{}",
"on-scroll-up": "hyprctl dispatch workspace e+1",
"on-scroll-down": "hyprctl dispatch workspace e-1",
},
"hyprland/workspaces": {
"on-scroll-up": "hyprctl dispatch workspace e+1",
"on-scroll-down": "hyprctl dispatch workspace e-1",
"all-outputs": true,
"on-click": "activate",
"format": "{icon}",
"format-icons": {
"1": "0",
"2": "1",
"3": "2",
"4": "3",
"5": "4",
"6": "5",
"7": "6",
"8": "7",
"9": "8",
"10": "9",
// "urgent": "",
// "active": "",
// "default": ""
}
},
"cpu": {
"interval": 1,
"format": "󰘚 {usage}%",
"max-length": 10,
"on-click": "alacritty --class floating -e htop"
},
"custom/updates": {
"exec": "pacman -Quq | wc -l | sed 's/^0$//'",
"interval": 60,
"format": "󰮯 {}"
},
"battery": {
"interval": 30,
"states": {
"warning": 30,
"critical": 15
},
"format-charging": "󰂅 {capacity}%",
"format": "{icon} {capacity}%",
"format-icons": ["󰂎", "󰁺", "󰁻", "󰁼", "󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"],
"tooltip": true
},
"custom/weather" : {
"tooltip" : true,
"format" : "{}",
"restart-interval" : 300,
"exec" : "~/.config/waybar/scripts/waybar-wttr.py",
"return-type" : "json"
},
"tray": {
"icon-size": 13,
// "tooltip": false,
"spacing": 10
},
"clock": {
"min-length": 10,
"interval": 1,
"format": "{:%d/%m %H:%M:%S}",
"timezones": ["Asia/Ho_Chi_Minh", "Europe/Paris"],
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
"actions": {
"on-scroll-up": "tz_up",
"on-scroll-down": "tz_down"
}
},
"pulseaudio#speaker": {
"format": "{icon} {volume}%",
"tooltip": false,
"format-muted": "󰖁",
"on-click": "pamixer -t",
// "on-click-right": "pamixer -t",
"on-scroll-up": "pamixer -i 5",
"on-scroll-down": "pamixer -d 5",
"scroll-step": 5,
"format-icons": {
"headphone": "󰋋",
"hands-free": "󰋋",
"headset": "󰋋",
"phone": "󰏲",
"portable": "󰏲",
"car": "󰄋",
"default": ["󰕿", "󰖀", "󰕾"]
}
},
"pulseaudio#microphone": {
"format": "{format_source}",
"tooltip": false,
"format-source": "󰍬 {volume}%",
"format-source-muted": "󰍭",
"on-click": "pamixer --default-source -t",
"on-scroll-up": "pamixer --default-source -i 5",
"on-scroll-down": "pamixer --default-source -d 5",
"scroll-step": 5
},
"hyprland/submap": {
"format": "(l)ock, (e)xit, (s)uspend, (h)ibernate, (r)eboot, (S)hutdown"
},
"custom/nvidia-load": {
"exec": ".config/waybar/scripts/nvidia-load.py",
"interval": 5,
"return-type": "json",
"format": "{}",
"tooltip": "{tooltip}",
"on-click": "alacritty --class floating -e nvtop"
},
"custom/nvidia-mem": {
"exec": ".config/waybar/scripts/nvidia-mem.py",
"interval": 5,
"return-type": "json",
"format": "{}",
"tooltip": "{tooltip}",
"on-click": "alacritty --class floating -e nvtop"
}
}

22
dunstconfig.nix Normal file
View file

@ -0,0 +1,22 @@
{
global = {
geometry = "750x5-20+20";
horizontal_padding = 8;
indicate_hidden = true;
shrink = true;
transparency = 20;
separator_height = 2;
frame_width = 3;
frame_color = "#000000";
font = "Monospace 11";
alignment = "left";
show_age_threshold = 60;
background = "#ffffff";
foreground = "#000000";
};
urgency_critical = {
background = "#ff9999";
};
}

108
fish.nix Normal file
View file

@ -0,0 +1,108 @@
{ pkgs, ... }:
{
enable = true;
loginShellInit = ''
set -gx fish_greeting
if test $(tty) = /dev/tty1
Hyprland
end
'';
interactiveShellInit = ''
# bind ctrl+s to fg
bind \cz 'fg 2>/dev/null; commandline -f repaint'
set -x DIRENV_LOG_FORMAT ""
'';
functions = {
# use "e" to open the text editor. if e job is paused, return to it
e.body = ''
jobs -c | grep $EDITOR \
|| $EDITOR $argv \
&& fg 2>/dev/null; commandline -f repaint
'';
lfcd.body = ''
set tmp (mktemp)
# `command` is needed in case `lfcd` is aliased to `lf`
command lf -last-dir-path=$tmp $argv
if test -f "$tmp"
set dir (cat $tmp)
rm -f $tmp
if test -d "$dir"
if test "$dir" != (pwd)
cd $dir
end
end
end
'';
upgrade-nix.body = ''
sudo nix-channel --update
sudo nixos-rebuild switch &| ${pkgs.nix-output-monitor}/bin/nom
nix-env -u '.*'
home-manager switch &| ${pkgs.nix-output-monitor}/bin/nom
'';
fish_prompt.body = ''
set -l last_pipestatus $pipestatus
set -lx __fish_last_status $status # Export for __fish_print_pipestatus.
set -l normal (set_color normal)
set -q fish_color_status
or set -g fish_color_status red
# Color the prompt differently when we're root
set -l color_cwd $fish_color_cwd
set -l suffix '>'
if functions -q fish_is_root_user; and fish_is_root_user
if set -q fish_color_cwd_root
set color_cwd $fish_color_cwd_root
end
set suffix '#'
end
# Write pipestatus
# If the status was carried over (if no command is issued or if `set` leaves the status untouched), don't bold it.
set -l bold_flag --bold
set -q __fish_prompt_status_generation; or set -g __fish_prompt_status_generation $status_generation
if test $__fish_prompt_status_generation = $status_generation
set bold_flag
end
set __fish_prompt_status_generation $status_generation
set -l status_color (set_color $fish_color_status)
set -l statusb_color (set_color $bold_flag $fish_color_status)
set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus)
# direnv status
set -l direnv_status (direnv status | grep -q "Found RC path" && echo " direnv")
# echo -n -s (prompt_login)' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) \
echo -n -s (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) \
(set_color -i yellow) $direnv_status $normal " "$prompt_status " "$suffix " "
'';
};
shellAliases = {
ls = "ls -hN --color=auto --group-directories-first";
grep = "grep --color=auto";
diff = "diff --color=auto";
bt = "bluetuith";
hm = "home-manager";
hms = "home-manager switch &| nom";
dev = "nix develop -c fish";
gparted = "nix-shell -p pkgs.gparted --run 'sudo -E gparted'";
ns = "nix shell";
nsp = "nix shell nixpkgs#";
f = "lfcd";
sxiv = "nsxiv";
};
plugins = [
{
name = "fish-lf-icons";
src = pkgs.fetchFromGitHub {
owner = "joshmedeski";
repo = "fish-lf-icons";
rev = "d1c47b2088e0ffd95766b61d2455514274865b4f";
sha256 = "sha256-6po/PYvq4t0K8Jq5/t5hXPLn80iyl3Ymx2Whme/20kc=";
};
}
];
}

38
flake.nix Normal file
View file

@ -0,0 +1,38 @@
{
description = "Home Manager configuration of ant";
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
hyprfocus.url = "github:VortexCoyote/hyprfocus";
};
outputs = { nixpkgs, home-manager, hyprfocus, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
flakes-pkgs = {
hyprfocus = hyprfocus.packages.${pkgs.system}.hyprfocus;
};
in {
homeConfigurations."ant" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [
./home.nix
];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix
extraSpecialArgs = {
inherit flakes-pkgs;
};
};
};
}

481
home.nix Normal file
View file

@ -0,0 +1,481 @@
let user = import ./name.nix; in
{ config, pkgs, flakes-pkgs, ... }:
{
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = user;
home.homeDirectory = "/home/${user}";
# This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release
# introduces backwards incompatible changes.
#
# You should not change this value, even if you update Home Manager. If you do
# want to update the value, then make sure to first check the Home Manager
# release notes.
home.stateVersion = "23.05"; # Please read the comment before changing.
# The home.packages option allows you to install Nix packages into your
# environment.
home.packages = with pkgs; [
betterbird
python3
dunst
ncdu
nsxiv
wl-clipboard
pamixer
pulsemixer
bluez
bluetuith
wtype
dmenu
keepmenu
dtrx
trash-cli
rofimoji
nnn
go-mtpfs
nix-output-monitor
libnotify
qbittorrent
go
unzip
pandoc
gnumake
xdg-utils
entr
# xdg-desktop-portal-wlr
# xdg-desktop-portal-hyprland
(catppuccin-gtk.override {
accents = [ "pink" ];
size = "compact";
tweaks = [ "black" ];
variant = "mocha";
})
davfs2
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
# ".config/fontconfig/fonts.conf".source = dotfiles/fonts.conf;
".config/waybar/config.jsonc".source = dotfiles/waybar.jsonc;
".config/waybar/style.css".source = dotfiles/waybar.css;
# ".config/kitty/kitty.conf".source = dotfiles/kitty/kitty.conf;
".config/kitty/light.conf".source = dotfiles/kitty/light.conf;
".config/kitty/dark.conf".source = dotfiles/kitty/dark.conf;
".config/rofi/colors-dark.rasi".source = dotfiles/rofi/colors-dark.rasi;
".config/rofi/colors-light.rasi".source = dotfiles/rofi/colors-light.rasi;
# ".config/rofi/config.rasi".source = dotfiles/rofi/config.rasi;
".config/rofi/theme.rasi".source = dotfiles/rofi/theme.rasi;
# ".config/dunst/dunstrc".source = dotfiles/dunstrc;
".config/keepmenu/config.ini".source = dotfiles/keepmenu.ini;
".bin/runmenu".source = pkgs.writers.writeBash "runmenu" ''
${config.programs.rofi.package}/bin/rofi -matching normal -sort -show run
'';
# ".bin/wl".source = bin/wl;
".bin/window_dir".source = pkgs.writers.writeBash "window_dir" ''
PID=$(${pkgs.hyprland}/bin/hyprctl activewindow | grep pid | cut -d' ' -f 2)
PID=$(echo $(ps --ppid $PID -o pid | tail -n1))
cwd=$(readlink /proc/"$PID"/cwd)
echo "$cwd"
'';
".bin/screenshot".source = (import ./bin/screenshot.nix) pkgs;
".bin/ocrzone".source = pkgs.writers.writeBash "ocrzone" ''
${pkgs.pkgs.sway-contrib.grimshot}/bin/grimshot save area - | \
${pkgs.tesseract}/bin/tesseract -l fra - - | \
${pkgs.wl-clipboard}/bin/wl-copy
'';
".bin/wifi-toggle".source = pkgs.writers.writeBash "wifi-toggle" ''
if [[ $(nmcli radio wifi) == "enabled" ]]; then
nmcli radio wifi off
else
nmcli radio wifi on
fi
'';
".bin/rofi-udisk".source = pkgs.writers.writeBash "rofi-udisk" ''
device=$(${pkgs.udiskie}/bin/udiskie-info -a -o "{ui_label} {in_use}" -f is_filesystem | \
${pkgs.gnused}/bin/sed 's/True$/[Mounted]/' | \
${pkgs.gnused}/bin/sed 's/False$//' | \
${config.programs.rofi.package}/bin/rofi -dmenu | \
${pkgs.coreutils}/bin/cut -d':' -f1)
if [ -n "$device" ] ; then
if ${pkgs.mount}/bin/mount | ${pkgs.gnugrep}/bin/grep "$device" ; then
echo "mounted"
${pkgs.udisks}/bin/udisksctl unmount -b $device
else
echo "not mounted"
${pkgs.udisks}/bin/udisksctl mount -b $device
fi
fi
'';
".bin/mount-android".source = pkgs.writers.writeBash "mount-android" ''
if ${pkgs.mount}/bin/mount | ${pkgs.gnugrep}/bin/grep $(realpath ~/android); then
umount $(realpath ~/android)
${pkgs.libnotify}/bin/notify-send "Android unmounted"
elif ${pkgs.simple-mtpfs}/bin/simple-mtpfs $(realpath ~/android); then
${pkgs.libnotify}/bin/notify-send "Android mounted in ~/android"
else
${pkgs.libnotify}/bin/notify-send "Can't find Android device"
fi
'';
".bin/dark".source = (import ./bin/dark.nix) pkgs;
};
home.sessionPath = [
"$HOME/.local/bin"
"$HOME/.bin"
];
home.sessionVariables = {
NIXOS_OZONE_WL = "1";
EDITOR = "nvim";
TERMINAL = "kitty";
TERM = "kitty";
NNN_TRASH = 1;
GOPATH = "${config.home.homeDirectory}/.local/share/go";
GOMODCACHE = "${config.home.homeDirectory}/.cache/go/pkg/mod";
};
home.keyboard.options = [
"caps:escape"
];
# xsession.enable = true;
# xsession.windowManager.command = "${pkgs.fish}/bin/fish --login";
wayland.windowManager.hyprland = (import ./hyprland.nix) { pkgs = pkgs; flakes-pkgs = flakes-pkgs; };
xdg = {
enable = true;
systemDirs.data = [ "${config.home.homeDirectory}/.local/share" ];
userDirs = {
enable = true;
createDirectories = false;
download = "${config.home.homeDirectory}/downloads";
templates = "${config.home.homeDirectory}/templates";
videos = "${config.home.homeDirectory}/videos";
desktop = "${config.home.homeDirectory}";
};
mimeApps = {
enable = true;
defaultApplications = {
"text/plain" = "nvim.desktop";
};
};
};
services.syncthing.enable = true;
systemd.user.services = {
battery-notify = {
Unit = {
Description = "Send notification when battery is low";
Wants = "battery-timer.timer";
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.writers.writeBash "battery-notify" ''
# ${pkgs.libnotify}/bin/notify-send $(${pkgs.coreutils}/bin/cat /sys/class/power_supply/BAT0/capacity)
if [[ $(${pkgs.coreutils}/bin/cat /sys/class/power_supply/BAT0/capacity) -lt 10 ]]; then
${pkgs.libnotify}/bin/notify-send -u critical "Battery is low"
fi
'' }";
};
};
};
systemd.user.timers = {
battery-timer = {
Unit = {
Description = "Execute battery-notify every minute";
};
Install = {
# enable the service
WantedBy = [ "default.target" ];
};
Timer = {
Unit = "battery-notify.service";
OnCalendar = "*-*-* *:*:00";
};
};
};
# services.darkman = {
# enable = true;
#
# lightModeScripts = {
# gtk-theme = ''
# ${pkgs.dconf}/bin/dconf write \
# /org/gnome/desktop/interface/color-scheme "'prefer-light'"
# '';
# # my-python-script = pkgs.writers.writePython3 "my-python-script" { } ''
# # print('Do something!')
# # '';
# };
#
# darkModeScripts = {
# gtk-theme = ''
# ${pkgs.dconf}/bin/dconf write \
# /org/gnome/desktop/interface/color-scheme "'prefer-dark'"
# '';
# # my-python-script = pkgs.writers.writePython3 "my-python-script" { } ''
# # print('Do something!')
# # '';
# };
#
# settings = {
# lat = 52.3;
# lng = 4.8;
# usegeoclue = true;
# };
# };
fonts.fontconfig.enable = true;
gtk = {
enable = true;
font = {
package = pkgs.inter;
name = "Inter";
};
theme = {
name = "Catppuccin-Latte-Compact-Pink-Light";
# name = "Catppuccin-Mocha-Compact-Pink-Dark";
package = pkgs.catppuccin-gtk.override {
accents = [ "pink" ];
size = "compact";
tweaks = [ ];
variant = "latte";
};
};
iconTheme = {
name = "Adwaita";
package = pkgs.gnome.adwaita-icon-theme;
};
cursorTheme = {
name = "Hackneyed";
package = pkgs.hackneyed;
};
};
qt = {
enable = true;
platformTheme = "gtk";
};
programs.direnv = {
enable = true;
nix-direnv.enable = true;
};
programs.rofi = {
enable = true;
package = pkgs.rofi-wayland;
plugins = [ pkgs.rofi-calc pkgs.rofi-emoji ];
# extraConfig = {
# "@theme" = "\"theme.rasi\"";
# };
theme = "theme.rasi";
};
programs.pistol.enable = true;
programs.lf =
(import ./lf.nix) { config = config; pkgs = pkgs; };
programs.fish = (import ./fish.nix) pkgs;
services.dunst.enable = true;
services.dunst.settings = import ./dunstconfig.nix;
services.kdeconnect.enable = true;
# programs.chromium = {
# enable = true;
# package = pkgs.ungoogled-chromium;
# dictioaries = [
# pkgs.hunspellDictsChromium.en_US
# pkgs.hunspellDictsChromium.fr_FR
# ];
# extensions = [
# { id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; } # ublock origin
# { id = "hfjbmagddngcpeloejdejnfgbamkjaeg"; } # vimium C
# ];
# };
programs.swaylock = {
enable = true;
package = pkgs.swaylock-effects;
# --screenshots \
# --clock \
# --indicator \
# --indicator-radius 100 \
# --indicator-thickness 7 \
# --effect-blur 7x5 \
# --effect-vignette 0.5:0.5 \
# --ring-color bb00cc \
# --key-hl-color 880033 \
# --line-color 00000000 \
# --inside-color 00000088 \
# --separator-color 00000000 \
# --grace 2 \
# --fade-in 0.2
settings = {
screenshots = true;
# clock = true;
font = "Sans:bold";
disable-caps-lock-text = true;
effect-blur = "7x5";
text-color = "ffffff";
layout-text-color = "ffffff";
ring-color = "000000";
key-hl-color = "dddddd";
line-color = "00000000";
inside-color = "00000088";
separator-color = "00000000";
ring-clear-color = "00000000";
line-clear-color = "00000000";
inside-clear-color = "00000000";
text-clear-color = "00000000";
};
};
services.swayidle = {
enable = true;
events = [{
event = "before-sleep";
command = "${config.programs.swaylock.package}/bin/swaylock -defF";
}
{
event = "after-resume";
command = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms on";
}
{
event = "lock";
command = "${config.programs.swaylock.package}/bin/swaylock -defF";
}];
timeouts = [{
timeout = 300;
command = "${config.programs.swaylock.package}/bin/swaylock -defF";
}
{
timeout = 900;
command = "${config.wayland.windowManager.hyprland.package}/bin/hyprctl dispatch dpms off";
}];
};
# services.swayidle = {
# enable = true;
# events = [
# { event = "after-resume"; command = "${pkgs.hyprland}/bin/hyprctl dispatch dpms on"; }
# ];
# timeouts = [{
# timeout = 10;
# command =
# "${pkgs.hyprland}/bin/hyprctl dispatch dpms off & swaylock";
# }];
#
# };
programs.kitty = {
enable = true;
font.name = "monospace";
font.size = 12;
settings = {
cursor_shape = "block";
default_pointer_shape = "arrow";
pointer_shape_when_dragging = "arrow";
enable_audio_bell = false;
placement_strategy = "top-left";
remember_window_size = false;
initial_window_width = 1300;
initial_window_height = 800;
confirm_os_window_close = 0;
resize_debounce_time = "0.1 0.1";
};
keybindings = {
"ctrl+shift+equal" = "change_font_size all +0.5";
"ctrl+shift+plus" = "change_font_size all +0.5";
"ctrl+shift+kp_add" = "change_font_size all +0.5";
"ctrl+shift+minus" = "change_font_size all -0.5";
"ctrl+shift+kp_subtract" = "change_font_size all -0.5";
};
shellIntegration.enableFishIntegration = true;
shellIntegration.mode = "no-cursor";
extraConfig = ''
include colors.conf
'';
};
programs.neovim = {
enable = true;
viAlias = true;
defaultEditor = true;
extraPackages = with pkgs; [
nodejs_21
gcc
ocamlPackages.lsp
ocamlPackages.ocamlformat
rnix-lsp
cargo
];
};
programs.mpv = {
enable = true;
config = {
keep-open = "yes";
osd-bar = "no";
};
scripts = with pkgs.mpvScripts; [
uosc
thumbfast
mpris
];
};
programs.waybar.enable = true;
programs.firefox.enable = true;
programs.zathura.enable = true;
programs.tmux = {
enable = true;
historyLimit = 60000;
escapeTime = 10;
keyMode = "vi";
mouse = true;
};
programs.git = {
enable = true;
userName = user;
userEmail = "${user}@domain.xyz";
};
programs.home-manager.enable = true;
}

310
hyprland.nix Normal file
View file

@ -0,0 +1,310 @@
{ pkgs, flakes-pkgs }:
{
enable = true;
xwayland.enable = true;
# plugins = [
# flakes-pkgs.hyprfocus
# ];
systemd.enable = true;
systemd.variables = [
"GDK_BACKEND=wayland,x11"
"QT_QPA_PLATFORM=\"wayland;xcb\""
"SDL_VIDEODRIVER=wayland"
"CLUTTER_BACKEND=wayland"
"XDG_CURRENT_DESKTOP=Hyprland"
"XDG_SESSION_TYPE=wayland"
"XDG_SESSION_DESKTOP=Hyprland"
"QT_AUTO_SCREEN_SCALE_FACTOR=1"
"WLR_NO_HARDWARE_CURSORS=1"
"XCURSOR_SIZE=24"
];
settings = {
input = {
kb_layout = "fr";
kb_variant = "";
kb_model = "pc105";
kb_options = "";
kb_rules = "";
touchpad = {
natural_scroll = "no";
};
sensitivity = 0.0;
numlock_by_default = true;
repeat_delay = 200;
repeat_rate = 50;
force_no_accel = true;
follow_mouse = 2;
};
general = {
gaps_in = 0;
gaps_out = 0;
border_size = 0;
"col.active_border" = "rgb(000000)";
"col.inactive_border" = "rgba(00000000)";
layout = "dwindle";
};
decoration = {
blur = {
enabled = false;
};
drop_shadow = true;
shadow_range = 8;
shadow_render_power = 4;
"col.shadow_inactive" = "rgba(1a1a1a33)";
"col.shadow" = "rgba(1a1a1aee)";
};
animations = {
enabled = true;
bezier = "myBezier, 0, 0, .58, 1";
animation = "global, 1, 1, myBezier";
};
dwindle = {
pseudotile = true;
preserve_split = true;
force_split = 2;
no_gaps_when_only = true;
};
master = {
new_is_master = true;
};
gestures = {
workspace_swipe = "off";
};
misc = {
disable_hyprland_logo = true;
enable_swallow = true;
mouse_move_enables_dpms = true;
key_press_enables_dpms = true;
# swallow_regex = "^(Alacritty)(.*)$";
# swallow_regex = "^(kitty)(.*)$";
};
windowrule = "float, floating";
"$mod" = "SUPER";
bind = [
"$mod, q, killactive"
"$mod SHIFT, q, exec, kill -9 $(hyprctl activewindow | grep pid | grep -E -o '[0-9]+$')"
"$mod, a, togglefloating"
"$mod SHIFT, a, workspaceopt, allfloat"
"$mod, Tab, togglesplit"
"$mod, P, pseudo"
"$mod, f, fullscreen"
"$mod SHIFT, f, fakefullscreen"
"$mod, Return, exec, kitty"
"$mod SHIFT, e, exec, rofimoji"
"$mod, c, exec, rofi -show calc -modi calc -no-show-match -no-sort"
"$mod, e, exec, $TERMINAL -e lf"
"$mod SHIFT, Return, exec, kitty --working-directory \"$(window_dir)\""
"$mod, w, exec, firefox"
"$mod SHIFT, w, exec, firefox --private-window"
"$mod, m, exec, kitty --class floating -e pulsemixer"
"$mod, d, exec, ~/.bin/runmenu"
"$mod, x, exec, keepmenu"
"$mod, z, exec, tmux new -spopup_terminal -d; kitty --class floating -e tmux a -t popup_terminal"
"$mod, f11, exec, ocrzone"
"$mod, f12, exec, kitty --class floating -e nmtui"
"$mod, f2, exec, dark"
"$mod, f3, exec, hyprctl reload"
"$mod, f4, exec, rofi-udisk"
"$mod, f5, exec, mount-android"
",XF86AudioRaiseVolume, exec, pamixer -i 5"
",XF86AudioLowerVolume, exec, pamixer -d 5"
",XF86AudioMute, exec, pamixer -t"
",XF86AudioMicMute, exec, pamixer -t --default-source"
",XF86MonBrightnessUp, exec, light -A 10"
",XF86MonBrightnessDown, exec, light -U 10"
"$mod,Print, exec, screenshot"
"$mod, agrave, submap, power"
"$mod, h, movefocus, l"
"$mod, l, movefocus, r"
"$mod, k, movefocus, u"
"$mod, j, movefocus, d"
"$mod, Left, movefocus, l"
"$mod, Right, movefocus, r"
"$mod, Up, movefocus, u"
"$mod, Down, movefocus, d"
"$mod SHIFT, h, movewindow, l"
"$mod SHIFT, l, movewindow, r"
"$mod SHIFT, k, movewindow, u"
"$mod SHIFT, j, movewindow, d"
"$mod SHIFT, Left, movewindow, l"
"$mod SHIFT, Right, movewindow, r"
"$mod SHIFT, Up, movewindow, u"
"$mod SHIFT, Down, movewindow, d"
"$mod, twosuperior, workspace, 1"
"$mod, ampersand, workspace, 2"
"$mod, eacute, workspace, 3"
"$mod, quotedbl, workspace, 4"
"$mod, apostrophe, workspace, 5"
"$mod, parenleft, workspace, 6"
"$mod, minus, workspace, 7"
"$mod, egrave, workspace, 8"
"$mod, underscore, workspace, 9"
"$mod, ccedilla, workspace, 10"
"$mod, rarenright, workspace, 11"
"$mod SHIFT, twosuperior, movetoworkspacesilent, 1"
"$mod SHIFT, ampersand, movetoworkspacesilent, 2"
"$mod SHIFT, eacute, movetoworkspacesilent, 3"
"$mod SHIFT, quotedbl, movetoworkspacesilent, 4"
"$mod SHIFT, apostrophe, movetoworkspacesilent, 5"
"$mod SHIFT, parenleft, movetoworkspacesilent, 6"
"$mod SHIFT, minus, movetoworkspacesilent, 7"
"$mod SHIFT, egrave, movetoworkspacesilent, 8"
"$mod SHIFT, underscore, movetoworkspacesilent, 9"
"$mod SHIFT, ccedilla, movetoworkspacesilent, 10"
"$mod SHIFT, rarenright, movetoworkspacesilent, 11"
];
bindm = [
"$mod, mouse:272, movewindow"
"$mod, mouse:273, resizewindow"
];
binde = [
"$mod SHIFT, h, moveactive, -60 0"
"$mod SHIFT, l, moveactive, 60 0"
"$mod SHIFT, k, moveactive, 0 -60"
"$mod SHIFT, j, moveactive, 0 60"
"$mod CTRL, h, resizeactive, -60 0"
"$mod CTRL, l, resizeactive, 60 0"
"$mod CTRL, k, resizeactive, 0 -60"
"$mod CTRL, j, resizeactive, 0 60"
"$mod SHIFT, Left, moveactive, -60 0"
"$mod SHIFT, Right, moveactive, 60 0"
"$mod SHIFT, Up, moveactive, 0 -60"
"$mod SHIFT, Down, moveactive, 0 60"
"$mod CTRL, Left, resizeactive, -60 0"
"$mod CTRL, Right, resizeactive, 60 0"
"$mod CTRL, Up, resizeactive, 0 -60"
"$mod CTRL, Down, resizeactive, 0 60"
];
# plugin:hyprfocus {
# enabled = yes
#
# keyboard_focus_animation = shrink
# mouse_focus_animation = flash
#
# bezier = bezIn, 0.5,0.0,1.0,0.5
# bezier = bezOut, 0.0,0.5,0.5,1.0
#
# flash {
# flash_opacity = 0.7
#
# in_bezier = bezIn
# in_speed = 0.5
#
# out_bezier = bezOut
# out_speed = 3
# }
#
# shrink {
# shrink_percentage = 0.8
#
# in_bezier = bezIn
# in_speed = 0.5
#
# out_bezier = bezOut
# out_speed = 3
# }
# }
"plugin:hyprfocus" = {
enabled = true;
keyboard_focus_animation = "flash";
mouse_focus_animation = "nothing";
# bezier = "bezIn, 0.5,0.0,1.0,0.5";
# bezier = "bezOut, 0.0,0.5,0.5,1.0";
flash = {
flash_opacity = 0.6;
in_speed = 0.3;
};
};
};
extraConfig =
let swaybgScript = (pkgs.writers.writeFish "display-background" ''
# find background image: only file in ~/.local/share/bg
set -l bg (find ~/.local/share/bg -type l)
${pkgs.swaybg}/bin/swaybg -m fill -i $bg
# set background
# ${pkgs.nix}/bin/nix-shell \
# -p pkgs.rubyPackages.gdk_pixbuf2 \
# --run "${pkgs.swaybg}/bin/swaybg -m fill -i $bg"
'');
in
''
# env = GDK_BACKEND,wayland,x11
# env = QT_QPA_PLATFORM,wayland;xcb
# env = SDL_VIDEODRIVER,wayland
# env = CLUTTER_BACKEND,wayland
#
# env = XDG_CURRENT_DESKTOP,Hyprland
# env = XDG_SESSION_TYPE,wayland
# env = XDG_SESSION_DESKTOP,Hyprland
# env = QT_AUTO_SCREEN_SCALE_FACTOR,1
monitor=,highrr,auto,1
monitor=HDMI-A-1,preferred,auto,1,mirror,eDP-1
exec = pkill swaybg; ${swaybgScript}
exec = pkill waybar; ${pkgs.waybar}/bin/waybar
submap = power
bind = ,s, exec, systemctl suspend
bind = ,s, submap, reset
bind = SHIFT,S,exec, shutdown now
bind = ,S, submap, reset
bind = ,h, exec, systemctl hibernate
bind = ,h, submap, reset
bind = ,e, exit
bind = ,e, submap, reset
bind = ,r, exec, reboot
bind = ,r, submap, reset
bind = ,l, exec, swaylock
bind = ,l, submap, reset
bind = ,escape, submap, reset
submap = reset
'';
}

195
lf.nix Normal file
View file

@ -0,0 +1,195 @@
{ config, pkgs, ... }:
{
enable = true;
commands = {
trash = ''''${{
set -f
${pkgs.trash-cli}/bin/trash $fx
}}'';
extract = ''''${{
set -f
${pkgs.dtrx}/bin/dtrx -n $fx
}}'';
compress_gzip = ''''${{
set -f
${pkgs.gnutar}/bin/tar Oc $(realpath --relative-to $PWD $f) | \
${pkgs.pigz}/bin/pigz -cv - > $f.tar.gz
}}'';
compress_zip = ''''${{
set -f
${pkgs.zip}/bin/zip -r $f.zip $(realpath --relative-to $PWD $f)
}}'';
compress_xz = ''''${{
set -f
${pkgs.gnutar}/bin/tar Oc $(realpath --relative-to $PWD $f) | \
${pkgs.pxz}/bin/pxz -cv - > $f.tar.xz
}}'';
compress_bzip2 = ''''${{
set -f
${pkgs.gnutar}/bin/tar Oc $(realpath --relative-to $PWD $f) | \
${pkgs.pbzip2}/bin/pbzip2 -cv - > $f.tar.bz2
}}'';
compress_zstd = ''''${{
set -f
${pkgs.gnutar}/bin/tar --zstd -cvf $f.tar.zst $(realpath --relative-to $PWD $f)
}}'';
compress_just_tar = ''''${{
set -f
${pkgs.gnutar}/bin/tar -cvf $f.tar $(realpath --relative-to $PWD $f)
}}'';
show_size = ''%{{
set -f
${pkgs.coreutils}/bin/du -sh $f
}}'';
ncdu = ''''${{
set -f
${pkgs.ncdu}/bin/ncdu $f
}}'';
# find = ''''${{
# set -f
# read -p
send-warpinator = ''%{{
set -f
${pkgs.cinnamon.warpinator}/bin/warpinator-send $f
}}'';
toggle_preview = ''%{{
if [ "$lf_preview" = "true" ]; then
lf -remote "send $id :set preview false; set ratios 1:5"
else
lf -remote "send $id :set preview true; set ratios 1:2:3"
fi
}}
'';
paste = ''&{{
set -- $(cat ~/.local/share/lf/files)
mode="$1"
shift
case "$mode" in
copy)
rsync -a --ignore-existing --info=progress2 -- "$@" . |
stdbuf -i0 -o0 -e0 tr '\r' '\n' |
while IFS= read -r line; do
lf -remote "send $id echo $line"
done
;;
move) mv -n -- "$@" .;;
esac
rm ~/.local/share/lf/files
lf -remote "send clear"
}}'';
bulk-rename = ''''${{
old="$(mktemp)"
new="$(mktemp)"
if [ -n "$fs" ]; then
fs="$(basename -a $fs)"
else
fs="$(ls)"
fi
printf '%s\n' "$fs" >"$old"
printf '%s\n' "$fs" >"$new"
$EDITOR "$new"
[ "$(wc -l < "$new")" -ne "$(wc -l < "$old")" ] && exit
paste "$old" "$new" | while IFS= read -r names; do
src="$(printf '%s' "$names" | cut -f1)"
dst="$(printf '%s' "$names" | cut -f2)"
if [ "$src" = "$dst" ] || [ -e "$dst" ]; then
continue
fi
mv -- "$src" "$dst"
done
rm -- "$old" "$new"
lf -remote "send $id unselect"
}}'';
alt-paste = ''&{{
if [ -n "$fs" ]; then
lf -remote "send $id $1; save-select"
fi
lf -remote "send $id paste"
}}'';
load-select = ''&{{
# skip if triggered via save-select from itself
if [ "$1" = "$id" ]; then
exit 0
fi
lf -remote "send $id unselect"
if [ -s ~/.local/share/lf/select ]; then
files=$(tr '\n' '\0' < ~/.local/share/lf/select | xargs -0 printf ' %q')
lf -remote "send $id toggle $files"
fi
}}'';
save-select = ''&{{
printf "%s" "$fs" > ~/.local/share/lf/select
lf -remote "send load-select $id"
}}'';
follow_link = ''%{{
lf -remote "send ''${id} select '$(readlink $f)'"
}}'';
open_folder_in_sxiv = ''%{{
nsxiv .
}}'';
};
keybindings = {
D = "trash";
x = "extract";
Xg = "compress_gzip";
Xz = "compress_zip";
Xx = "compress_xz";
Xb = "compress_bzip2";
Xs = "compress_zstd";
Xt = "compress_just_tar";
as = "show_size";
an = "ncdu";
ar = "bulk-rename";
af = "follow_link";
ai = "open_folder_in_sxiv";
aw = "send-warpinator";
E = "$nvim";
zp = "toggle_preview";
p = "alt-paste copy";
P = "alt-paste cut";
"<space>" = ":toggle; down; save-select";
u = ":unselect; save-select";
v = ":invert; save-select";
};
# previewer.source = "${pkgs.pistol}/bin/pistol";
previewer.source = pkgs.writers.writeBash "pistol" ''
file=$1
w=$2
h=$3
x=$4
y=$5
if [[ "$( ${pkgs.file}/bin/file -Lb --mime-type "$file")" =~ ^image ]]; then
kitty +kitten icat --silent --stdin no --transfer-mode file --place \
"''${w}x''${h}@''${x}x''${y}" "$file" < /dev/null > /dev/tty
exit 1
fi
${pkgs.pistol}/bin/pistol "$file"
'';
settings = {
icons = true;
ifs = "\\n";
cleaner =
let
cleaner = pkgs.writers.writeBash "cleaner" ''
kitty +kitten icat --clear --stdin no --silent --transfer-mode file < /dev/null > /dev/tty
'';
in
"${cleaner}";
};
extraConfig = ''
load-select
setlocal ${config.xdg.userDirs.download} sortby time
setlocal ${config.xdg.userDirs.download} reverse
setlocal ${config.xdg.userDirs.download} set info size:time
'';
}