Merge branch 'main' of github.com:ckrinitsin/dotfiles
Christian Krinitsin code@krinitsin.xyz
Tue, 04 Jun 2024 22:00:30 +0200
17 files changed,
294 insertions(+),
134 deletions(-)
jump to
M
bin/bluetooth-devices
→
bin/bluetooth-devices
@@ -2,11 +2,34 @@ #!/bin/sh
# # This program lists all paired devices which you can select from, the selected one -# will be connected +# will be connected / disconnected # -# Opens dmenu prompt, which lets you decide which device you want to connect to -DEVICE=$(bluetoothctl devices | sed 's/[^ ]* //' | sed 's/[^ ]* //' | dmenu) +connect_bluetooth() { + local MAC=$1 + local DEVICE=$2 + if bluetoothctl connect $MAC | grep -q 'successful' + then + notify-send -t 5000 -r 2954 -u normal " Connected successfully from" " $DEVICE" + else + notify-send -t 5000 -r 2954 -u normal " Couldn't connect from" " $DEVICE" + fi +} + + +disconnect_bluetooth() { + local MAC=$1 + local DEVICE=$2 + if bluetoothctl disconnect $MAC | grep -q 'Successful' + then + notify-send -t 5000 -r 2954 -u normal " Disconnected successfully from" " $DEVICE" + else + notify-send -t 5000 -r 2954 -u normal " Couldn't disconnect from" " $DEVICE" + fi +} + +# Opens dmenu prompt, which lets you decide which device you want to connect to / disconnect from +DEVICE=$(bluetoothctl devices | sed 's/[^ ]* //' | sed 's/[^ ]* //' | dmenu -i) # If dmenu was cancelled, exit program if [ $? -ne 0 ]; then@@ -16,10 +39,12 @@
# Get MAC adress of the device you selected MAC=$(bluetoothctl devices | grep "$DEVICE" | sed 's/[^ ]* //' | cut -d ' ' -f1) -# Send a notify whether the connection was successful -if bluetoothctl connect $MAC | grep -q 'successful' +# If bluetooth device is already connected, disconnect, else connect +CONNECTED=$(bluetoothctl devices Connected | cut -f3 -d ' ') +if echo $CONNECTED | grep $DEVICE then - notify-send -t 5000 -r 2954 -u normal " Connected successfully to" " $DEVICE" + disconnect_bluetooth $MAC $DEVICE else - notify-send -t 5000 -r 2954 -u normal " Couldn't connect to" " $DEVICE" + connect_bluetooth $MAC $DEVICE fi +
A
bin/gaps
@@ -0,0 +1,60 @@
+#!/usr/bin/python3 + +# +# Interactive gaps, depending on number of applications on a workspace +# + +import i3ipc +i3 = i3ipc.Connection() +print("starting") + +#################### -- window management -- #################### +def two_gap(): + i3.command('gaps left current set 200') + i3.command('gaps right current set 200') + +def one_gap(): + i3.command('gaps right current set 400') + i3.command('gaps left current set 400') + +def remove_gaps(): + i3.command('gaps left current set 0') + i3.command('gaps right current set 0') + +def make_window_normal(workspace): + i3.command('fullscreen disable') + +def make_window_fullscreen(workspace): + i3.command('fullscreen enable') + +def manage_new_close_window(self, e): + focused = i3.get_tree().find_focused() + workspace = focused.workspace() + monitor = workspace.ipc_data['output'] + + if monitor != "HDMI-A-1": + return + + y = len(workspace.nodes) + + if y > 2: + remove_gaps() + return + + if y == 2: + two_gap() + return + + one_gap() + return +########################### -- end -- ########################### + + +i3.on('window::new', manage_new_close_window) +i3.on('window::close', manage_new_close_window) +i3.on('window::move', manage_new_close_window) +i3.on('window::focus', manage_new_close_window) +i3.on('workspace::empty', manage_new_close_window) +i3.on('workspace::init', manage_new_close_window) + +i3.main()
A
bin/volume_brightness
@@ -0,0 +1,102 @@
+#!/bin/bash +# original source: https://gitlab.com/Nmoleo/i3-volume-brightness-indicator + +# taken from here: https://gitlab.com/Nmoleo/i3-volume-brightness-indicator + +# See README.md for usage instructions +bar_color="#d3c6aa" +volume_step=2 +brightness_step=2.5 +max_volume=100 + +# Uses regex to get volume from pactl +function get_volume { + pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '[0-9]{1,3}(?=%)' | head -1 +} + +# Uses regex to get mute status from pactl +function get_mute { + pactl get-sink-mute @DEFAULT_SINK@ | grep -Po '(?<=Mute: )(yes|no)' +} + +# Uses regex to get brightness from xbacklight +function get_brightness { + brightnessctl | grep "Current brightness" | cut -d '(' -f 2 | cut -d '%' -f 1 +} + +# Returns a mute icon, a volume-low icon, or a volume-high icon, depending on the volume +function get_volume_icon { + volume=$(get_volume) + mute=$(get_mute) + if [ "$mute" == "yes" ] ; then + volume_icon=" " + elif [ "$volume" -eq 0 ]; then + volume_icon=" " + elif [ "$volume" -lt 50 ]; then + volume_icon=" " + else + volume_icon=" " + fi +} + +# Always returns the same icon - I couldn't get the brightness-low icon to work with fontawesome +function get_brightness_icon { + brightness_icon=" " +} + +# Displays a volume notification using dunstify +function show_volume_notif { + volume=$(get_mute) + get_volume_icon + if [ "$mute" == "yes" ]; then + dunstify -t 1000 -r 2593 -u normal "$volume_icon" -h int:value:0 -h string:hlcolor:$bar_color + else + dunstify -t 1000 -r 2593 -u normal "$volume_icon $volume%" -h int:value:$volume -h string:hlcolor:$bar_color + fi +} + +# Displays a brightness notification using dunstify +function show_brightness_notif { + brightness=$(get_brightness) + get_brightness_icon + dunstify -t 1000 -r 2593 -u normal "$brightness_icon $brightness%" -h int:value:$brightness -h string:hlcolor:$bar_color +} + +# Main function - Takes user input, "volume_up", "volume_down", "brightness_up", or "brightness_down" +case $1 in + volume_up) + # Unmutes and increases volume, then displays the notification + pactl set-sink-mute @DEFAULT_SINK@ 0 + volume=$(get_volume) + if [ $(( "$volume" + "$volume_step" )) -gt $max_volume ]; then + pactl set-sink-volume @DEFAULT_SINK@ $max_volume% + else + pactl set-sink-volume @DEFAULT_SINK@ +$volume_step% + fi + show_volume_notif + ;; + + volume_down) + # Raises volume and displays the notification + pactl set-sink-volume @DEFAULT_SINK@ -$volume_step% + show_volume_notif + ;; + + volume_mute) + # Toggles mute and displays the notification + pactl set-sink-mute @DEFAULT_SINK@ toggle + show_volume_notif + ;; + + brightness_up) + # Increases brightness and displays the notification + brightnessctl set +$brightness_step% + show_brightness_notif + ;; + + brightness_down) + # Decreases brightness and displays the notification + brightnessctl set $brightness_step%- + show_brightness_notif + ;; +esac
M
dunstify/.config/dunst/dunstrc
→
dunstify/.config/dunst/dunstrc
@@ -4,7 +4,7 @@ [global]
### Display ### # Which monitor should the notifications be displayed on. - monitor = 0 + monitor = 1 # Display notification on focused monitor. Possible modes are: # mouse: follow mouse pointer
M
nvim/.config/nvim/init.lua
→
nvim/.config/nvim/init.lua
@@ -2,4 +2,5 @@ vim.loader.enable()
require('core/options') require('core/keymaps') +require('core/autocmd') require('core/lazy')
A
nvim/.config/nvim/lua/core/autocmd.lua
@@ -0,0 +1,9 @@
+vim.api.nvim_create_autocmd( + "BufWritePost", + { + pattern = "*.tex", + callback = function() + vim.cmd("silent make --silent") + end, + } +)
M
nvim/.config/nvim/lua/core/keymaps.lua
→
nvim/.config/nvim/lua/core/keymaps.lua
@@ -12,3 +12,5 @@
vim.keymap.set('n', '<C-x>', ':bd<CR>', {}) vim.keymap.set('n', '<C-j>', ':bp<CR>', {}) vim.keymap.set('n', '<C-k>', ':bn<CR>', {}) + +vim.keymap.set('n', '<leader>ma', ':w<CR>:make<CR>', {})
M
nvim/.config/nvim/lua/plugins/appearance.lua
→
nvim/.config/nvim/lua/plugins/appearance.lua
@@ -5,7 +5,7 @@ "nvim-treesitter/nvim-treesitter",
build = ":TSUpdate", config = function () require("nvim-treesitter.configs").setup({ - ensure_installed = { "c", "lua", "vim", "rust", "toml" }, + ensure_installed = { "c", "lua", "vim", "rust", "toml", "latex" }, sync_install = false, highlight = { enable = true }, indent = { enable = true },
M
nvim/.config/nvim/lua/plugins/lspconfig.lua
→
nvim/.config/nvim/lua/plugins/lspconfig.lua
@@ -36,6 +36,11 @@ require'lspconfig'.clangd.setup{
capabilities = require('cmp_nvim_lsp').default_capabilities(), } + require'lspconfig'.texlab.setup{ + capabilities = require('cmp_nvim_lsp').default_capabilities(), + settings = { texlab = { diagnostics = { ignoredPatterns = { 'Unused label'} } } } + } + vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('UserLspConfig', {}), callback = function(ev)
A
scripts/getty@tty1.service
@@ -0,0 +1,60 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later +# +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Getty on %I +Documentation=man:agetty(8) man:systemd-getty-generator(8) +Documentation=https://0pointer.de/blog/projects/serial-console.html +After=systemd-user-sessions.service plymouth-quit-wait.service getty-pre.target + +# If additional gettys are spawned during boot then we should make +# sure that this is synchronized before getty.target, even though +# getty.target didn't actually pull it in. +Before=getty.target +IgnoreOnIsolate=yes + +# IgnoreOnIsolate causes issues with sulogin, if someone isolates +# rescue.target or starts rescue.service from multi-user.target or +# graphical.target. +Conflicts=rescue.service +Before=rescue.service + +# On systems without virtual consoles, don't start any getty. Note +# that serial gettys are covered by serial-getty@.service, not this +# unit. +ConditionPathExists=/dev/tty0 + +[Service] +# the VT is cleared by TTYVTDisallocate +# The '-o' option value tells agetty to replace 'login' arguments with an +# option to preserve environment (-p), followed by '--' for safety, and then +# the entered username. +ExecStart=-/sbin/agetty -a chris --noclear - $TERM +Type=idle +Restart=always +RestartSec=0 +UtmpIdentifier=%I +StandardInput=tty +StandardOutput=tty +TTYPath=/dev/%I +TTYReset=yes +TTYVHangup=yes +TTYVTDisallocate=yes +IgnoreSIGPIPE=no +SendSIGHUP=yes +ImportCredential=agetty.* +ImportCredential=login.* + +# Unset locale for the console getty since the console has problems +# displaying some internationalized messages. +UnsetEnvironment=LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT LC_IDENTIFICATION + +[Install] +WantedBy=getty.target +DefaultInstance=tty1
M
scripts/install-packages.sh
→
scripts/install-packages.sh
@@ -1,9 +1,13 @@
#!/usr/bin/bash # install packages -sudo pacman -S pacman-contrib python-tldextract pass gnupg base-devel libnotify wl-clipboard qt6-wayland xorg-server-xwayland nerd-fonts zoxide waybar bison startup-notification flex wayland-protocols pkg-config cmake gcc alacritty dunst neovim qutebrowser starship xdg-user-dirs zathura zathura-pdf-mupdf meson ninja +sudo pacman -S fzf grim pacman-contrib python-tldextract pass gnupg base-devel libnotify wl-clipboard qt6-wayland xorg-server-xwayland nerd-fonts zoxide waybar bison startup-notification flex wayland-protocols pkg-config cmake gcc alacritty dunst neovim qutebrowser starship xdg-user-dirs zathura zathura-pdf-mupdf meson ninja sudo pacman -S pipewire pipewire-audio pipewire-alsa pipewire-pulse pavucontrol + +sudo pacman -S texlive-basic texlive-bibtexextra texlive-latex texlive-mathscience texlive-latexrecommended texlive-latexextra texlive-binextra + +yay -S grimshot # install rofi and dmenu for wayland git clone https://github.com/lbonn/rofi.git /tmp/rofi
M
scripts/lsp.sh
→
scripts/lsp.sh
@@ -1,4 +1,4 @@
#!/usr/bin/bash -sudo pacman -S lua-language-server clang rust-analyzer +sudo pacman -S lua-language-server clang rust-analyzer texlab
M
sway/.config/sway/config
→
sway/.config/sway/config
@@ -109,18 +109,18 @@
bindsym $mod+Shift+t exec thunderbird bindsym $mod+Shift+w exec qutebrowser bindsym $mod+Return exec alacritty -bindsym $mod+Shift+e exec ~/.config/waybar/scripts/powermenu -bindsym $mod+p exec ~/.config/waybar/scripts/blur-lock +bindsym $mod+Shift+e exec powermenu +bindsym $mod+p exec blur-lock bindsym $mod+Shift+c reload bindsym $mod+Shift+r restart # multimedia -bindsym XF86MonBrightnessUp exec --no-startup-id ~/.config/waybar/scripts/volume_brightness.sh brightness_up -bindsym XF86MonBrightnessDown exec --no-startup-id ~/.config/waybar/scripts/volume_brightness.sh brightness_down -bindsym XF86AudioRaiseVolume exec --no-startup-id ~/.config/waybar/scripts/volume_brightness.sh volume_up -bindsym XF86AudioLowerVolume exec --no-startup-id ~/.config/waybar/scripts/volume_brightness.sh volume_down -bindsym XF86AudioMute exec --no-startup-id ~/.config/waybar/scripts/volume_brightness.sh volume_mute +bindsym XF86MonBrightnessUp exec --no-startup-id volume_brightness brightness_up +bindsym XF86MonBrightnessDown exec --no-startup-id volume_brightness brightness_down +bindsym XF86AudioRaiseVolume exec --no-startup-id volume_brightness volume_up +bindsym XF86AudioLowerVolume exec --no-startup-id volume_brightness volume_down +bindsym XF86AudioMute exec --no-startup-id volume_brightness volume_mute bindsym XF86AudioMicMute exec amixer sset Capture toggle bindsym XF86AudioPlay exec playerctl play-pause bindsym XF86AudioPause exec playerctl play-pause@@ -129,7 +129,7 @@ bindsym XF86AudioPrev exec playerctl previous
bindsym $mod+Ctrl+s exec screenshot # custom scripts -bindsym $mod+Shift+o exec zathura-fzf /home/chris/uni/ +bindsym $mod+Shift+o exec zathura-fzf /home/chris/uni/ /home/chris/downloads bindsym $mod+Shift+b exec bluetooth-devices bindsym $mod+w exec qtb-load-session bindsym $mod+Shift+s exec run-spotify-player
M
waybar/.config/waybar/config
→
waybar/.config/waybar/config
@@ -84,7 +84,7 @@ // "thermal-zone": 2,
// "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input", "critical-threshold": 80, "format": "{icon} {temperatureC}°C", - "format-icons": ["", "", ""], + "format-icons": ["", "", ""], "tooltip": false }, "backlight": {@@ -115,22 +115,16 @@ "format-wifi": " {signalStrength}%",
"format-ethernet": " {ipaddr}/{cidr}", "format-linked": " {ifname} (No IP)", "format-disconnected": " ⚠", - "on-click": "nm-connection-editor", + "on-click": "alacritty -e nmtui", "tooltip": false }, "pulseaudio": { // "scroll-step": 1, // %, can be a float "format": "{icon} {volume}%", - "format-bluetooth": "{volume}% {icon} ", - "format-bluetooth-muted": " ", - "format-muted": " ", + "format-bluetooth": "{volume}% ", + "format-bluetooth-muted": " ", + "format-muted": " ", "format-icons": { - "headphone": "", - "hands-free": "", - "headset": "", - "phone": "", - "portable": "", - "car": "", "default": ["", " ", " "] }, "on-click": "pavucontrol"@@ -149,8 +143,8 @@ // "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name
}, "custom/pacman": { "format": " {}", - "interval": 3600, // every hour - "exec": "checkupdates | wc -l", // # of updates + "interval": 30, // every hour + "exec": "pacman -Qu | wc -l", // # of updates "exec-if": "exit 0", // always run; consider advanced run conditions "on-click": "alacritty -e yay; pkill -SIGRTMIN+8 waybar", // update system "signal": 8,
D
waybar/.config/waybar/scripts/volume_brightness.sh
@@ -1,102 +0,0 @@
-#!/bin/bash -# original source: https://gitlab.com/Nmoleo/i3-volume-brightness-indicator - -# taken from here: https://gitlab.com/Nmoleo/i3-volume-brightness-indicator - -# See README.md for usage instructions -bar_color="#d3c6aa" -volume_step=2 -brightness_step=2.5 -max_volume=100 - -# Uses regex to get volume from pactl -function get_volume { - pactl get-sink-volume @DEFAULT_SINK@ | grep -Po '[0-9]{1,3}(?=%)' | head -1 -} - -# Uses regex to get mute status from pactl -function get_mute { - pactl get-sink-mute @DEFAULT_SINK@ | grep -Po '(?<=Mute: )(yes|no)' -} - -# Uses regex to get brightness from xbacklight -function get_brightness { - brightnessctl | grep "Current brightness" | cut -d '(' -f 2 | cut -d '%' -f 1 -} - -# Returns a mute icon, a volume-low icon, or a volume-high icon, depending on the volume -function get_volume_icon { - volume=$(get_volume) - mute=$(get_mute) - if [ "$mute" == "yes" ] ; then - volume_icon=" " - elif [ "$volume" -eq 0 ]; then - volume_icon=" " - elif [ "$volume" -lt 50 ]; then - volume_icon=" " - else - volume_icon=" " - fi -} - -# Always returns the same icon - I couldn't get the brightness-low icon to work with fontawesome -function get_brightness_icon { - brightness_icon=" " -} - -# Displays a volume notification using dunstify -function show_volume_notif { - volume=$(get_mute) - get_volume_icon - if [ "$mute" == "yes" ]; then - dunstify -t 1000 -r 2593 -u normal "$volume_icon" -h int:value:0 -h string:hlcolor:$bar_color - else - dunstify -t 1000 -r 2593 -u normal "$volume_icon $volume%" -h int:value:$volume -h string:hlcolor:$bar_color - fi -} - -# Displays a brightness notification using dunstify -function show_brightness_notif { - brightness=$(get_brightness) - get_brightness_icon - dunstify -t 1000 -r 2593 -u normal "$brightness_icon $brightness%" -h int:value:$brightness -h string:hlcolor:$bar_color -} - -# Main function - Takes user input, "volume_up", "volume_down", "brightness_up", or "brightness_down" -case $1 in - volume_up) - # Unmutes and increases volume, then displays the notification - pactl set-sink-mute @DEFAULT_SINK@ 0 - volume=$(get_volume) - if [ $(( "$volume" + "$volume_step" )) -gt $max_volume ]; then - pactl set-sink-volume @DEFAULT_SINK@ $max_volume% - else - pactl set-sink-volume @DEFAULT_SINK@ +$volume_step% - fi - show_volume_notif - ;; - - volume_down) - # Raises volume and displays the notification - pactl set-sink-volume @DEFAULT_SINK@ -$volume_step% - show_volume_notif - ;; - - volume_mute) - # Toggles mute and displays the notification - pactl set-sink-mute @DEFAULT_SINK@ toggle - show_volume_notif - ;; - - brightness_up) - # Increases brightness and displays the notification - brightnessctl set +$brightness_step% - show_brightness_notif - ;; - - brightness_down) - # Decreases brightness and displays the notification - brightnessctl set $brightness_step%- - show_brightness_notif - ;; -esac