From 8ea71ee2baf86d32f810bc6f6c560e6677cc2e09 Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Wed, 13 Sep 2023 21:45:58 -0600 Subject: updates again --- x/.xinitrc | 2 +- x/spawn-alacritty | 37 +++++++++++++++++++++++++++++++++++++ x/spawn-alacritty.sh | 37 ------------------------------------- 3 files changed, 38 insertions(+), 38 deletions(-) create mode 100755 x/spawn-alacritty delete mode 100755 x/spawn-alacritty.sh (limited to 'x') diff --git a/x/.xinitrc b/x/.xinitrc index 8f20975..d71925a 100644 --- a/x/.xinitrc +++ b/x/.xinitrc @@ -56,7 +56,7 @@ light -S 30 & # pacmd set-sink-volume alsa_output.pci-0000_03_00.6.HiFi__hw_Generic_1__sink 0 & # set up wallpaper -feh --bg-fill ~/git/wallpapers-exorcist/gruvbox/mountains-2.jpg +feh --bg-fill ~/Pictures/Wallpapers/unsplash-beach.jpg # apply Xresources xrdb -merge ~/.Xresources diff --git a/x/spawn-alacritty b/x/spawn-alacritty new file mode 100755 index 0000000..7292478 --- /dev/null +++ b/x/spawn-alacritty @@ -0,0 +1,37 @@ +#!/bin/bash +# Stole from https://github.com/alacritty/alacritty/issues/808#issuecomment-334200570 +# +# Spawn a new instance of Alacritty using the CWD of the currently focused +# Alacritty process. +# +# This is useful in environment like i3 where terminals are opened using a +# key-combination while another terminal is already focused. +# +# If the script is run with a non-Alacritty window in focus or a non-compliant +# version of Alacritty, an instance will be spawned in the user's $HOME. + +ACTIVE_WINDOW=$(xdotool getactivewindow) +ACTIVE_WM_CLASS=$(xprop -id $ACTIVE_WINDOW | grep WM_CLASS) +if [[ $ACTIVE_WM_CLASS == *"Alacritty"* ]] +then + # Get PID. If _NET_WM_PID isn't set, bail. + PID=$(xprop -id $ACTIVE_WINDOW | grep _NET_WM_PID | grep -oP "\d+") + if [[ "$PID" == "" ]] + then + WINIT_X11_SCALE_FACTOR=1 alacritty + fi + # Get first child of terminal + CHILD_PID=$(pgrep -P $PID) + if [[ "$PID" == "" ]] + then + WINIT_X11_SCALE_FACTOR=1 alacritty + fi + # Get current directory of child. The first child should be the shell. + pushd "/proc/${CHILD_PID}/cwd" + SHELL_CWD=$(pwd -P) + popd + # Start alacritty with the working directory + WINIT_X11_SCALE_FACTOR=1 alacritty --working-directory "$SHELL_CWD" +else + WINIT_X11_SCALE_FACTOR=1 alacritty +fi diff --git a/x/spawn-alacritty.sh b/x/spawn-alacritty.sh deleted file mode 100755 index 7292478..0000000 --- a/x/spawn-alacritty.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# Stole from https://github.com/alacritty/alacritty/issues/808#issuecomment-334200570 -# -# Spawn a new instance of Alacritty using the CWD of the currently focused -# Alacritty process. -# -# This is useful in environment like i3 where terminals are opened using a -# key-combination while another terminal is already focused. -# -# If the script is run with a non-Alacritty window in focus or a non-compliant -# version of Alacritty, an instance will be spawned in the user's $HOME. - -ACTIVE_WINDOW=$(xdotool getactivewindow) -ACTIVE_WM_CLASS=$(xprop -id $ACTIVE_WINDOW | grep WM_CLASS) -if [[ $ACTIVE_WM_CLASS == *"Alacritty"* ]] -then - # Get PID. If _NET_WM_PID isn't set, bail. - PID=$(xprop -id $ACTIVE_WINDOW | grep _NET_WM_PID | grep -oP "\d+") - if [[ "$PID" == "" ]] - then - WINIT_X11_SCALE_FACTOR=1 alacritty - fi - # Get first child of terminal - CHILD_PID=$(pgrep -P $PID) - if [[ "$PID" == "" ]] - then - WINIT_X11_SCALE_FACTOR=1 alacritty - fi - # Get current directory of child. The first child should be the shell. - pushd "/proc/${CHILD_PID}/cwd" - SHELL_CWD=$(pwd -P) - popd - # Start alacritty with the working directory - WINIT_X11_SCALE_FACTOR=1 alacritty --working-directory "$SHELL_CWD" -else - WINIT_X11_SCALE_FACTOR=1 alacritty -fi -- cgit v1.2.3