diff --git a/nvim/init.lua b/nvim/init.lua index 06d0a7a..911d91b 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -894,3 +894,29 @@ require('lazy').setup({ -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et + +-- Function to update padding in the Alacritty configuration +local function update_padding(line_nr, from, to, file_path) + vim.cmd(string.format("silent !sed -i '%ss/%s/%s/' %s", line_nr, from, to, file_path)) +end + +-- Function to increase padding (on VimLeavePre) +local function increase_padding() + update_padding('07', '0', '20', '~/.config/alacritty/alacritty.yml') + update_padding('08', '0', '20', '~/.config/alacritty/alacritty.yml') +end + +-- Function to decrease padding (on VimEnter) +local function decrease_padding() + update_padding('07', '20', '0', '~/.config/alacritty/alacritty.yml') + update_padding('08', '20', '0', '~/.config/alacritty/alacritty.yml') +end + +-- Autocommands to adjust padding on VimEnter and VimLeavePre +vim.cmd [[ + augroup ChangeAlacrittyPadding + autocmd! + autocmd VimEnter * lua decrease_padding() + autocmd VimLeavePre * lua increase_padding() + augroup END +]] diff --git a/scripts/timechange b/scripts/timechange new file mode 100755 index 0000000..251b08f --- /dev/null +++ b/scripts/timechange @@ -0,0 +1,40 @@ + +#!/usr/bin/env bash + +# Check if IP argument is provided +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Set the NTP server IP +NTP_SERVER="$1" + +# Stop ntpd service +echo "Stopping ntpd service..." +sudo systemctl stop ntpd + +# Sync time using ntpdate +echo "Synchronizing time with $NTP_SERVER..." +sudo ntpdate "$NTP_SERVER" + +# Prompt for setting time zone +echo "Please enter the desired time zone (e.g., UTC, Asia/Kuwait):" +read -r TIMEZONE + +# Set the time zone +if sudo timedatectl set-timezone "$TIMEZONE"; then + echo "Time zone set to $TIMEZONE." +else + echo "Failed to set time zone to $TIMEZONE. Please ensure the input is correct." + exit 1 +fi + +# Start ntpd service +echo "Starting ntpd service..." +sudo systemctl start ntpd + +# Display the current time settings +echo "Time synchronized successfully with $NTP_SERVER and time zone set to $TIMEZONE." +timedatectl +