Added configurations and scripts to home-manager

master
hheik 2023-09-23 23:51:28 +03:00
parent 1ad92b7d32
commit 8718a51406
22 changed files with 568 additions and 2 deletions

172
.config/i3/config Normal file
View File

@ -0,0 +1,172 @@
set $mod Mod4
gaps inner 0
gaps outer 0
bindsym $mod+minus gaps inner current plus 32
bindsym $mod+plus gaps inner current minus 32
bindsym $mod+Shift+minus gaps outer current plus 32
bindsym $mod+Shift+plus gaps outer current minus 32
bindsym Caps_Lock exec --no-startup-id sleep 0.2s && refresh-status-bar
bindsym Num_Lock exec --no-startup-id sleep 0.2s && refresh-status-bar
# Lock Screen
bindsym $mod+Shift+l exec --no-startup-id lock
# Scratchpad
bindsym $mod+Shift+Tab move scratchpad
bindsym $mod+Tab scratchpad show
# Keyboard layout
bindsym $mod+l exec --no-startup-id toggleKeymap
# Opens up a dmenu of your repos
bindsym $mod+F1 exec --no-startup-id open-repo
bindsym $mod+F2 exec --no-startup-id open-repo lvim
bindsym $mod+F3 exec --no-startup-id open-repo terminal
# Opens pavucontrol
bindsym $mod+t exec --no-startup-id pavucontrol
# Take screenshot
bindsym $mod+c exec --no-startup-id cap -F
bindsym --whole-window $mod+button2 floating toggle
# Font for window titles. Will also be used by the bar unless a different font
font pango:monospace 8
exec --no-startup-id nm-applet
# Use pactl to adjust volume in PulseAudio.
#set $refresh_i3status killall -SIGUSR1 i3status
set $refresh_i3status refresh-status-bar
bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
# mocp
bindsym $mod+Mod1+Right exec --no-startup-id /usr/local/bin/mocp --next
bindsym $mod+Mod1+Left exec --no-startup-id /usr/local/bin/mocp --previous
bindsym $mod+Mod1+Down exec --no-startup-id /usr/local/bin/mocp --toggle-pause
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
bindsym $mod+Return exec i3-sensible-terminal
# kill focused window
bindsym $mod+Shift+q kill
# start dmenu (a program launcher)
bindsym $mod+d exec dmenu_run -p 'run:'
# change focus
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+h split h
# split in vertical orientation
bindsym $mod+v split v
# enter fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+a focus parent
# focus the child container
#bindsym $mod+d focus child
# Define names for default workspaces for which we configure key bindings later on.
# We use variables to avoid repeating the names in multiple places.
set $ws1 "1"
set $ws2 "2"
set $ws3 "3"
set $ws4 "4"
set $ws5 "5"
set $ws6 "6"
set $ws7 "7"
set $ws8 "8"
set $ws9 "9"
set $ws10 "10"
# switch to workspace
bindsym $mod+1 workspace number $ws1
bindsym $mod+2 workspace number $ws2
bindsym $mod+3 workspace number $ws3
bindsym $mod+4 workspace number $ws4
bindsym $mod+5 workspace number $ws5
bindsym $mod+6 workspace number $ws6
bindsym $mod+7 workspace number $ws7
bindsym $mod+8 workspace number $ws8
bindsym $mod+9 workspace number $ws9
bindsym $mod+0 workspace number $ws10
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number $ws1; workspace number $ws1
bindsym $mod+Shift+2 move container to workspace number $ws2; workspace number $ws2
bindsym $mod+Shift+3 move container to workspace number $ws3; workspace number $ws3
bindsym $mod+Shift+4 move container to workspace number $ws4; workspace number $ws4
bindsym $mod+Shift+5 move container to workspace number $ws5; workspace number $ws5
bindsym $mod+Shift+6 move container to workspace number $ws6; workspace number $ws6
bindsym $mod+Shift+7 move container to workspace number $ws7; workspace number $ws7
bindsym $mod+Shift+8 move container to workspace number $ws8; workspace number $ws8
bindsym $mod+Shift+9 move container to workspace number $ws9; workspace number $ws9
bindsym $mod+Shift+0 move container to workspace number $ws10; workspace number $ws10
set $focuser_mode Focuser mode: Escape/Enter to exit
bindsym $mod+KP_Insert mode "$focuser_mode"
mode "$focuser_mode" {
bindsym Left focus left
bindsym Down focus down
bindsym Up focus up
bindsym Right focus right
bindsym Escape mode "default"
bindsym Return mode "default"
bindsym $mod+KP_Insert mode "default"
}
# reload the configuration file
bindsym $mod+Shift+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-msg exit"
# resize window (you can also use the mouse for that)
bindsym $mod+Control+Left resize shrink width 128 px or 4 ppt
bindsym $mod+Control+Down resize grow height 128 px or 4 ppt
bindsym $mod+Control+Up resize shrink height 128 px or 4 ppt
bindsym $mod+Control+Right resize grow width 128 px or 4 ppt
### Use custom status bar
bar {
# status_command i3status
status_command py3status -c $HOME/.config/i3status/config
tray_output primary
}

85
.config/i3status/config Normal file
View File

@ -0,0 +1,85 @@
# i3status configuration file.
# see "man i3status" for documentation.
# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!
general {
colors = true
interval = 5
}
order += "spotify"
order += "mocPlayer"
order += "keyboard_locks"
order += "volume_status"
order += "sysdata"
# order += "volume"
order += "keyboardLayout"
# order += "ipv6"
order += "disk /"
order += "wireless _first_"
order += "ethernet _first_"
#order += "battery all"
#order += "load"
order += "tztime local"
sysdata {
format = "Mem: [\?color=mem_used_percent {mem_used_percent}% {mem_used}/{mem_total}] {mem_used_unit} : CPU [\?color=cpu_used_percent {format_cpu}]"
format_cpu = "[\?if=used_percent>80 █|[\?if=used_percent>70 ▇|[\?if=used_percent>60 ▆|[\?if=used_percent>50 ▅|[\?if=used_percent>40 ▄|[\?if=used_percent>30 ▃|[\?if=used_percent>20 ▂|[\?if=used_percent>10 ▁|_]]]]]]]]"
format_cpu_separator = ""
thresholds = [(0, "good"), (60, "degraded"), (80, "bad")]
cache_timeout = 2
}
volume_status {
blocks = "_▁▂▃▄▅▆▇█"
# blocks = "abcdefghi"
max_volume = 100
# format = "Vol: {percentage}%"
# cache_timeout = 1
}
keyboard_locks {
# format = '\?color=good [\?if=num_lock NUM][\?soft ][\?if=caps_lock CAPS][\?soft ][\?if=scroll_lock SCR]'
format = '[\?if=caps_lock&color=good CAPS|\?color=bad CAPS] [\?if=num_lock&color=good NUM|\?color=bad NUM]'
}
spotify {
button_next = 5
button_play_pause = 1
button_previous = 4
# format = "{title} - {artist}"
format = "\[ {title} \]"
format_down = ""
# cache_timeout = 5
}
wireless _first_ {
format_up = "W: (%quality at %essid) %ip"
format_down = "W: down"
}
ethernet _first_ {
# if you use %speed, i3status requires root privileges
format_up = "E: %ip (%speed)"
format_down = "E: down"
}
battery all {
format = "%status %percentage %remaining"
}
tztime local {
format = "%d-%m-%Y %H:%M:%S"
}
load {
format = "%1min"
}
disk "/" {
format = "%avail"
}

View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
import os
kbCommand = 'setxkbmap -query | grep layout | awk \'{print toupper($2)}\''
class Py3status:
def keyboardLayout(self):
layout = os.popen(kbCommand).read().strip()
return {
'full_text': layout,
'cached_until': self.py3.time_in(5)
}

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
import os
mocCommand = 'mocp-playing'
class Py3status:
def mocPlayer(self):
playing = os.popen(mocCommand).read().strip()
if not playing:
return {
'cached_until': self.py3.time_in(5),
'full_text': '',
}
return {
'cached_until': self.py3.time_in(5),
'composite': [
{
'full_text': '[ ',
},
{
'full_text': playing,
'color': '#22FFFF',
},
{
'full_text': ' ]',
}
]
}

View File

@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
import os
vol = "pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,';"
class Py3status:
def volumeBar(self):
volString = os.popen(vol).read().strip()
return {
'full_text': volString,
'cached_until': self.py3.time_in(5)
}

1
.config/nvim/init.vim Normal file
View File

@ -0,0 +1 @@
lua require("editor")

View File

@ -0,0 +1,16 @@
vim.opt.relativenumber = true
vim.opt.number = true
-- Indentation
vim.opt.shiftwidth = 4
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.expandtab = false
vim.opt.listchars:append({ tab = " - ", multispace = ".", leadmultispace = " " })
vim.opt.list = true
-- Soft wrapping
-- TODO: Add toggle keymap
vim.opt.wrap = true
vim.opt.linebreak = true
vim.opt.breakindent = true

65
.config/terminator/config Normal file
View File

@ -0,0 +1,65 @@
[global_config]
inactive_color_offset = 1.0
[keybindings]
new_tab = ""
cycle_next = ""
cycle_prev = ""
go_next = ""
go_prev = ""
go_up = ""
go_down = ""
go_left = ""
go_right = ""
rotate_cw = ""
rotate_ccw = ""
split_auto = ""
split_horiz = ""
split_vert = ""
close_term = ""
close_window = ""
resize_up = ""
resize_down = ""
resize_left = ""
resize_right = ""
move_tab_right = ""
move_tab_left = ""
toggle_zoom = ""
scaled_zoom = ""
next_tab = ""
prev_tab = ""
full_screen = ""
reset = ""
reset_clear = ""
hide_window = ""
group_all = ""
ungroup_all = ""
ungroup_win = ""
group_tab = ""
ungroup_tab = ""
new_window = ""
new_terminator = ""
insert_number = ""
insert_padded = ""
edit_window_title = ""
edit_tab_title = ""
edit_terminal_title = ""
layout_launcher = ""
preferences_keybindings = ""
help = ""
[profiles]
[[default]]
background_color = "#14131d"
font = envypn 11
foreground_color = "#888888"
show_titlebar = False
scrollbar_position = hidden
use_system_font = False
[layouts]
[[default]]
[[[window0]]]
type = Window
parent = ""
[[[child1]]]
type = Terminal
parent = window0
[plugins]

41
.local/scripts/cap Executable file
View File

@ -0,0 +1,41 @@
#!/usr/bin/env bash
stamp() {
date '+%s'
}
usage="Usage: $(basename $0) [options]
-F capture fullscreen
-q quiet
-h show this text"
while getopts 'Fqh' arg; do
case "$arg" in
F)
fullscreen=true;;
q)
quiet=true;;
h)
echo "$usage"
exit 0;;
*)
echo "$usage" >&2
exit 1;;
esac
done
shift $((OPTIND-1))
tmp_file="$(mktemp tmp.XXXXXXXXXX.png)"
file="$HOME/pics/screenshot_$(stamp).png"
if [ -n "$fullscreen" ]; then
DISPLAY=:0 import -window root "$file"
else
DISPLAY=:0 import "$tmp_file"
convert "$tmp_file" -shave 1x1 "$file"
rm "$tmp_file"
fi
xclip -selection clipboard -t image/png -i "$file"
[ -z "$quiet" ] && notify-send -i "$file" 'Screenshot taken'
[ -z "$quiet" ] && echo "$file"

23
.local/scripts/dl-chapters Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
set -euo 'pipefail'
die() {
echo "$@" 1>&2
exit 1
}
data="$(yt-dlp -j "$1")"
dir="$HOME/Music/$(echo "$data" | jq -r '.title' | sed 's;/; ;g')"
id="$(echo "$data" | jq -r '.id')"
[ -z "$dir" ] && exit 1
[ -z "$id" ] && exit 1
echo "id: '$id'"
mkdir -p "$dir"
cd "$dir" || exit 1
yt-dlp -x --split-chapters "$1" || die "yt-dlp exited with an error code"
title="$(basename "$(find ./ -name "* \[$id\]*" | sort -r | head -n1 | sed "s; \[$id\].*;;")")"
[ -z "$title" ] && die "Could not get title"
find ./ -name "$title \[$id\]*" -exec rm {} \;
find ./ -name "$title - *" | while read file; do
mv "$file" "$(echo "$file" | sed "s;$title - ;;" | sed "s; \[$id\];;")"
done

5
.local/scripts/dl-playlist Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -euo 'pipefail'
cd "$HOME/Music" || exit 1
yt-dlp -x -o '%(playlist_title)s/%(playlist_index)s - %(title)s.%(ext)s' "$1"

3
.local/scripts/drepos Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
message="${1:-Open repository:}"
getrepos | dmenu -l 50 -i -p "$message"

3
.local/scripts/getrepos Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
repo_dir="$HOME/repo"
ls "$repo_dir"

4
.local/scripts/lock Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
setxkbmap us
killall -USR1 py3status
i3lock -c 000000

11
.local/scripts/mocp-playing Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
[ ! -e "$HOME/.moc/pid" ] && exit 0
title=""
title="${title:-$(mocp -Q %title)}"
title="${title:-$(mocp -Q %song)}"
title="${title:-$(mocp -Q %file)}"
basename "$title"

3
.local/scripts/open-nvim Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
[ -e "$1" ] && terminator -p programming -x nvim "$1"

28
.local/scripts/open-repo Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env bash
editor=${1:-ranger}
open_terminal=true
terminal_profile='default'
# Editor specific cases
case "$editor" in
*)
;;
esac
prefix=''
# Terminal command
[ "$open_terminal" = true ] && prefix="terminator -p $terminal_profile -x "
repo="$(drepos "Open repository in $editor:")"
[ -z "$repo" ] && exit 1
repo_path="$HOME/repo/$repo"
[ ! -d "$repo_path" ] && exit 1
if [ "$editor" = 'terminal' ]; then
terminator -p default --working-directory "$repo_path"
else
$prefix"$editor" "$repo_path"
fi

View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
killall -USR1 .py3status-wrapped

3
.local/scripts/set-wallpaper Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
sleep 1
feh --bg-fill $HOME/.backgrounds/wallpaper

11
.local/scripts/toggleKeymap Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
layout="$(setxkbmap -query | grep layout | awk '{print $2}')"
if [ "$layout" != "us" ]; then
setxkbmap us
pretty="United States"
else
setxkbmap fi nodeadkeys
pretty="Finnish"
fi
refresh-status-bar

View File

@ -86,6 +86,7 @@
nixpkgs.config.allowUnfree = true;
environment.systemPackages = with pkgs; [
# Basics
neovim
wget
curl
@ -94,7 +95,23 @@
git
ranger
openssl
xorg.xwininfo
killall
# General development
mold
clang
# Bevy related
pkg-config
xorg.libXcursor
xorg.libXrandr
xorg.libXi
vulkan-tools
vulkan-headers
vulkan-loader
vulkan-validation-layers
alsaLib
libudev-zero
];
# This value determines the NixOS release from which the default

View File

@ -32,7 +32,20 @@
neofetch
terminator
moc
xclip
imagemagick
libnotify
xorg.xwininfo
python310Packages.py3status
];
file.".config" = {
source = ./.config;
recursive = true;
};
file.".local" = {
source = ./.local;
recursive = true;
};
};
programs = {
@ -42,7 +55,7 @@
shellAliases = {
bye = "(echo 'Press enter to confirm shutdown...'); read && shutdown 0";
};
historyControl = [ "ignorespace" ];
historyControl = [ "ignorespace" "ignoredups" ];
historyFile = "$HOME/.bash_history";
historyFileSize = 1000000;
bashrcExtra = ''
@ -58,6 +71,8 @@ export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
[ -d "$HOME/.local/scripts" ] && PATH="$HOME/.local/scripts:$PATH"
[ -d "$HOME/.local/bin" ] && PATH="$HOME/.local/bin:$PATH"
[ -d "$HOME/.yarn/bin" ] && PATH="$HOME/.yarn/bin:$PATH"
export EDITOR=nvim
'';
};
git = {