mirror of
https://gitlab.com/dabruh/dotfiles.git
synced 2024-12-27 04:18:11 +01:00
Compare commits
No commits in common. "4973b9f4d2abdcc8ae05884d263a7d33b34d8b56" and "a9ccc784827ed480f599886277119e46112a0c1e" have entirely different histories.
4973b9f4d2
...
a9ccc78482
2 changed files with 15 additions and 34 deletions
|
@ -16,7 +16,6 @@ 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"
|
||||||
|
@ -65,27 +64,26 @@ rm_env_path_entry() {
|
||||||
del_entry="${2:?Missing entry to delete}"
|
del_entry="${2:?Missing entry to delete}"
|
||||||
new_entries=""
|
new_entries=""
|
||||||
|
|
||||||
for entry in $(echo "$src_entries" | $_tr ':' ' '); do
|
echo "$src_entries" | $_tr ':' '\n' | while read -r entry; 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
|
||||||
|
|
||||||
[ -n "$new_entries" ] && trim "$new_entries" ":"
|
trim "$new_entries" ":"
|
||||||
echo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
modify_env_path() {
|
modify_env_path() {
|
||||||
mode="${1:?Missing mode}"
|
mode="${1:?Missing mode}"
|
||||||
entries="$2"
|
entries="${2:?Missing entries}"
|
||||||
change="${3:?Missing change}"
|
change="${3:?Missing change}"
|
||||||
|
|
||||||
[ -n "$entries" ] && entries="$(trim "$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
|
||||||
for entry in $(echo "$change" | $_tr ':' ' '); do
|
echo "$change" | $_tr ':' '\n' | while read -r entry; 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"
|
||||||
|
@ -96,16 +94,15 @@ modify_env_path() {
|
||||||
entries="${temp_entries#:}:$entries"
|
entries="${temp_entries#:}:$entries"
|
||||||
;;
|
;;
|
||||||
append)
|
append)
|
||||||
for entry in $(echo "$change" | $_tr ':' ' '); do
|
echo "$change" | $_tr ':' '\n' | while read -r entry; 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)
|
||||||
for entry in $(echo "$change" | $_tr ':' ' '); do
|
echo "$change" | $_tr ':' '\n' | while read -r entry; 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
|
||||||
;;
|
;;
|
||||||
|
@ -115,8 +112,7 @@ modify_env_path() {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[ -n "$entries" ] && trim "$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,20 +65,14 @@ 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 matches=0
|
local monitor
|
||||||
|
|
||||||
for monitor in "$@"; do
|
for monitor in "$@"; do
|
||||||
if monitor_exist "$monitor"; then
|
if ! monitor_exist "$monitor"; then
|
||||||
echo "$monitor"
|
return 1
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +285,7 @@ move_nonexistent_i3_workspaces() {
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local primary_monitor monitor_count monitors=() profile_found=false exists
|
local primary_monitor monitor_count monitors=() profile_found=false
|
||||||
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"
|
||||||
|
@ -300,7 +294,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 2>&1; then
|
elif usb_devices_exist all exact "HP, Inc HP USB-C Universal Dock" >/dev/null; 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"
|
||||||
|
@ -308,8 +302,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[@]}" >/dev/null; then
|
if monitors_exist "${monitor_array[@]}"; then
|
||||||
echo "Applying work profile for ${monitor_array[*]}"
|
echo "Applying dock 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 \
|
||||||
|
@ -318,15 +312,6 @@ 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