diff options
| author | Christian Krinitsin <code@krinitsin.xyz> | 2024-06-03 22:05:39 +0200 |
|---|---|---|
| committer | Christian Krinitsin <code@krinitsin.xyz> | 2024-06-03 22:05:39 +0200 |
| commit | 4a719347c682dc51e8886292b1a19cb0c6a57741 (patch) | |
| tree | cd285bf70e5cf39da7fdcdb9ca6120cdb75bfc08 | |
| parent | 72ecba9ca9488ab0b95a2973077326ed9770a0cf (diff) | |
| download | dotfiles-4a719347c682dc51e8886292b1a19cb0c6a57741.tar.gz dotfiles-4a719347c682dc51e8886292b1a19cb0c6a57741.zip | |
enhance latex support in nvim, rewrite bluetooth, add new gaps script, change waybar pacman segment
| -rwxr-xr-x | bin/bluetooth-devices | 39 | ||||
| -rwxr-xr-x | bin/gaps | 60 | ||||
| -rw-r--r-- | nvim/.config/nvim/init.lua | 1 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/core/autocmd.lua | 9 | ||||
| -rw-r--r-- | nvim/.config/nvim/lua/plugins/appearance.lua | 2 | ||||
| -rw-r--r-- | waybar/.config/waybar/config | 11 |
6 files changed, 106 insertions, 16 deletions
diff --git a/bin/bluetooth-devices b/bin/bluetooth-devices index 5cc4876..f5fe284 100755 --- a/bin/bluetooth-devices +++ b/bin/bluetooth-devices @@ -2,11 +2,34 @@ # # 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 @@ fi # 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 + diff --git a/bin/gaps b/bin/gaps new file mode 100755 index 0000000..10ac7a2 --- /dev/null +++ b/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() diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 15c11dd..b0f092c 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -2,4 +2,5 @@ vim.loader.enable() require('core/options') require('core/keymaps') +require('core/autocmd') require('core/lazy') diff --git a/nvim/.config/nvim/lua/core/autocmd.lua b/nvim/.config/nvim/lua/core/autocmd.lua new file mode 100644 index 0000000..dfecbf8 --- /dev/null +++ b/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, + } +) diff --git a/nvim/.config/nvim/lua/plugins/appearance.lua b/nvim/.config/nvim/lua/plugins/appearance.lua index 425a7de..ae7959d 100644 --- a/nvim/.config/nvim/lua/plugins/appearance.lua +++ b/nvim/.config/nvim/lua/plugins/appearance.lua @@ -5,7 +5,7 @@ return { 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 }, diff --git a/waybar/.config/waybar/config b/waybar/.config/waybar/config index 0fa2078..2300c46 100644 --- a/waybar/.config/waybar/config +++ b/waybar/.config/waybar/config @@ -121,15 +121,10 @@ "pulseaudio": { // "scroll-step": 1, // %, can be a float "format": "{icon} {volume}%", - "format-bluetooth": "{volume}% {icon} ", + "format-bluetooth": "{volume}% ", "format-bluetooth-muted": " ", "format-muted": " ", "format-icons": { - "headphone": "", - "headset": " ", - "phone": "", - "portable": "", - "car": "", "default": ["", " ", " "] }, "on-click": "pavucontrol" @@ -148,8 +143,8 @@ }, "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, |