mirror of
https://gitlab.com/dabruh/dotfiles.git
synced 2024-12-25 09:35:57 +01:00
Compare commits
4 commits
a9ccc78482
...
4973b9f4d2
Author | SHA1 | Date | |
---|---|---|---|
|
4973b9f4d2 | ||
|
c7145e8b4a | ||
|
4cac467d32 | ||
|
f5676e638d |
2 changed files with 34 additions and 15 deletions
|
@ -16,6 +16,7 @@ export CHROME_EXECUTABLE=chromium # For Flutter
|
||||||
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
||||||
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||||
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||||
|
export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/share}"
|
||||||
|
|
||||||
# Clean home:
|
# Clean home:
|
||||||
export ANDROID_HOME="$XDG_DATA_HOME/Android/Sdk"
|
export ANDROID_HOME="$XDG_DATA_HOME/Android/Sdk"
|
||||||
|
@ -64,26 +65,27 @@ rm_env_path_entry() {
|
||||||
del_entry="${2:?Missing entry to delete}"
|
del_entry="${2:?Missing entry to delete}"
|
||||||
new_entries=""
|
new_entries=""
|
||||||
|
|
||||||
echo "$src_entries" | $_tr ':' '\n' | while read -r entry; do
|
for entry in $(echo "$src_entries" | $_tr ':' ' '); do
|
||||||
if [ "$entry" != "$del_entry" ]; then
|
if [ "$entry" != "$del_entry" ]; then
|
||||||
new_entries="$new_entries:$entry"
|
new_entries="$new_entries:$entry"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
trim "$new_entries" ":"
|
[ -n "$new_entries" ] && trim "$new_entries" ":"
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
modify_env_path() {
|
modify_env_path() {
|
||||||
mode="${1:?Missing mode}"
|
mode="${1:?Missing mode}"
|
||||||
entries="${2:?Missing entries}"
|
entries="$2"
|
||||||
change="${3:?Missing change}"
|
change="${3:?Missing change}"
|
||||||
|
|
||||||
entries="$(trim "$entries" ":")"
|
[ -n "$entries" ] && entries="$(trim "$entries" ":")"
|
||||||
|
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
prepend)
|
prepend)
|
||||||
temp_entries="" # Will hold the new entries in the correct order
|
temp_entries="" # Will hold the new entries in the correct order
|
||||||
echo "$change" | $_tr ':' '\n' | while read -r entry; do
|
for entry in $(echo "$change" | $_tr ':' ' '); do
|
||||||
[ -z "$entry" ] && continue # Skip empty entries
|
[ -z "$entry" ] && continue # Skip empty entries
|
||||||
[ -d "$entry" ] || continue # Skip non-existent directories
|
[ -d "$entry" ] || continue # Skip non-existent directories
|
||||||
temp_entries="$temp_entries:$entry"
|
temp_entries="$temp_entries:$entry"
|
||||||
|
@ -94,15 +96,16 @@ modify_env_path() {
|
||||||
entries="${temp_entries#:}:$entries"
|
entries="${temp_entries#:}:$entries"
|
||||||
;;
|
;;
|
||||||
append)
|
append)
|
||||||
echo "$change" | $_tr ':' '\n' | while read -r entry; do
|
for entry in $(echo "$change" | $_tr ':' ' '); do
|
||||||
[ -z "$entry" ] && continue # Skip empty entries
|
[ -z "$entry" ] && continue # Skip empty entries
|
||||||
[ -d "$entry" ] || continue # Skip non-existent directories
|
[ -d "$entry" ] || continue # Skip non-existent directories
|
||||||
entries="$entries:$entry"
|
entries="$entries:$entry"
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
delete)
|
delete)
|
||||||
echo "$change" | $_tr ':' '\n' | while read -r entry; do
|
for entry in $(echo "$change" | $_tr ':' ' '); do
|
||||||
[ -z "$entry" ] && continue # Skip empty entries
|
[ -z "$entry" ] && continue # Skip empty entries
|
||||||
|
[ -z "$entries" ] && break # nothing left to remove
|
||||||
entries=$(rm_env_path_entry "$entries" "$entry")
|
entries=$(rm_env_path_entry "$entries" "$entry")
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
|
@ -112,7 +115,8 @@ modify_env_path() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
trim "$entries" ":"
|
[ -n "$entries" ] && trim "$entries" ":"
|
||||||
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
prepend_paths="$HOME/.local/bin:$HOME/.cargo/bin:$FLUTTER_HOME/bin:$GOPATH/bin:$KREW_ROOT/bin"
|
prepend_paths="$HOME/.local/bin:$HOME/.cargo/bin:$FLUTTER_HOME/bin:$GOPATH/bin:$KREW_ROOT/bin"
|
||||||
|
|
|
@ -65,14 +65,20 @@ monitor_exist() {
|
||||||
# monitors_exist checks if the specified monitors are connected to the system
|
# monitors_exist checks if the specified monitors are connected to the system
|
||||||
# $1..$n: The monitor names to search for
|
# $1..$n: The monitor names to search for
|
||||||
monitors_exist() {
|
monitors_exist() {
|
||||||
local monitor
|
local monitor matches=0
|
||||||
|
|
||||||
for monitor in "$@"; do
|
for monitor in "$@"; do
|
||||||
if ! monitor_exist "$monitor"; then
|
if monitor_exist "$monitor"; then
|
||||||
return 1
|
echo "$monitor"
|
||||||
|
matches=$((matches + 1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ "$matches" -ne "$#" ]; then
|
||||||
|
echo "Amount of devices does not match the amount of arguments" 1>&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +291,7 @@ move_nonexistent_i3_workspaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local primary_monitor monitor_count monitors=() profile_found=false
|
local primary_monitor monitor_count monitors=() profile_found=false exists
|
||||||
primary_monitor=$(get_monitors primary | cut -d',' -f1)
|
primary_monitor=$(get_monitors primary | cut -d',' -f1)
|
||||||
monitor_count=$(get_monitors connected | wc -l)
|
monitor_count=$(get_monitors connected | wc -l)
|
||||||
echo "Monitors connected: $monitor_count"
|
echo "Monitors connected: $monitor_count"
|
||||||
|
@ -294,7 +300,7 @@ main() {
|
||||||
echo "Applying laptop-only profile"
|
echo "Applying laptop-only profile"
|
||||||
xrandr --auto
|
xrandr --auto
|
||||||
profile_found=true
|
profile_found=true
|
||||||
elif usb_devices_exist all exact "HP, Inc HP USB-C Universal Dock" >/dev/null; then
|
elif usb_devices_exist all exact "HP, Inc HP USB-C Universal Dock" >/dev/null 2>&1; then
|
||||||
monitors=(
|
monitors=(
|
||||||
"eDP-1,DVI-I-1-1,DVI-I-2-2"
|
"eDP-1,DVI-I-1-1,DVI-I-2-2"
|
||||||
"eDP-1,DVI-I-2-2,DVI-I-3-3"
|
"eDP-1,DVI-I-2-2,DVI-I-3-3"
|
||||||
|
@ -302,8 +308,8 @@ main() {
|
||||||
|
|
||||||
for monitor in "${monitors[@]}"; do
|
for monitor in "${monitors[@]}"; do
|
||||||
IFS=',' read -r -a monitor_array <<<"$monitor"
|
IFS=',' read -r -a monitor_array <<<"$monitor"
|
||||||
if monitors_exist "${monitor_array[@]}"; then
|
if monitors_exist "${monitor_array[@]}" >/dev/null; then
|
||||||
echo "Applying dock profile for ${monitor_array[*]}"
|
echo "Applying work profile for ${monitor_array[*]}"
|
||||||
xrandr \
|
xrandr \
|
||||||
--output "${monitor_array[0]}" --mode 1920x1200 --rotate normal --pos 1200x1474 --primary \
|
--output "${monitor_array[0]}" --mode 1920x1200 --rotate normal --pos 1200x1474 --primary \
|
||||||
--output "${monitor_array[1]}" --mode 1920x1200 --rotate left --pos 0x0 \
|
--output "${monitor_array[1]}" --mode 1920x1200 --rotate left --pos 0x0 \
|
||||||
|
@ -312,6 +318,15 @@ main() {
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
elif usb_devices_exist all exact "Lenovo ThinkPad USB-C Dock Audio" >/dev/null 2>&1; then
|
||||||
|
monitor_array=(eDP-1 DP-1-0.3 DP-1-0.1)
|
||||||
|
if monitors_exist "${monitor_array[@]}" >/dev/null; then
|
||||||
|
echo "Applying home profile for ${monitor_array[*]}"
|
||||||
|
xrandr \
|
||||||
|
--output "${monitor_array[0]}" --mode 2560x1440 --rotate normal --pos 0x480 --primary \
|
||||||
|
--output "${monitor_array[1]}" --mode 3440x1440 --rotate normal --pos 2560x480 \
|
||||||
|
--output "${monitor_array[2]}" --mode 1920x1200 --rotate right --pos 6000x0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! "$profile_found"; then
|
if ! "$profile_found"; then
|
||||||
|
|
Loading…
Reference in a new issue