Add Keyboard module

This commit is contained in:
Stephan Raabe 2024-01-01 15:08:52 +01:00
parent 2dd04cba6c
commit ee8a6c6b51
8 changed files with 135 additions and 1 deletions

View File

@ -230,3 +230,46 @@ _replaceInFile() {
sleep 2
fi
}
# replaceLineInFile $findText $customtext $targetFile
_replaceLineInFile() {
# Set function parameters
find_string="$1"
new_string="$2"
file_path=$3
# Counters
find_line_counter=0
line_found=0
if [ -f $file_path ] ;then
# Detect Line
while read -r line
do
((find_line_counter++))
if [[ $line = *$find_string* ]]; then
# echo "Start found in $start_line_counter"
line_found=$find_line_counter
break
fi
done < "$file_path"
if [[ ! "$line_found" == "0" ]] ;then
#Remove the line
sed -i "$line_found d" $file_path
# Add the new line
sed -i "$line_found i $new_string" $file_path
else
echo "ERROR: Target line not found."
sleep 2
fi
else
echo "ERROR: Target file not found."
sleep 2
fi
}

View File

@ -269,5 +269,15 @@ echo -e "${NONE}"
echo "nm-applet restored."
fi
# Restore Keyboard natural_scroll
targetFile="$HOME/dotfiles-versions/$version/hypr/conf/keyboard.conf"
settingsFile="$HOME/dotfiles/.settings/keyboard_naturalscroll"
if [ -f $settingsFile ] ;then
findMarker="natural_scroll"
customtext="$(cat $settingsFile)"
_replaceLineInFile "$findMarker" "$customtext" "$targetFile"
echo "keyboard natural_scroll restored."
fi
echo ""
fi

View File

@ -3,7 +3,8 @@ https://gitlab.com/stephan-raabe/dotfiles/-/releases/2.7.1
--------------------------------------------------------
Hyprland:
- Add optional network-manager applet support. Can be activated in Settings script System/nm-applet
- Settings: Show/Hide network module
- Show/Hide network module in Settings script
- New Settings for keyboard (incl. natural_scroll for touchpads)
Version 2.7
https://gitlab.com/stephan-raabe/dotfiles/-/releases/2.7

View File

@ -265,6 +265,49 @@ _replaceInFile() {
fi
}
# replaceLineInFile $findText $customtext $targetFile
_replaceLineInFile() {
# Set function parameters
find_string="$1"
new_string="$2"
file_path=$3
# Counters
find_line_counter=0
line_found=0
if [ -f $file_path ] ;then
# Detect Line
while read -r line
do
((find_line_counter++))
if [[ $line = *$find_string* ]]; then
# echo "Start found in $start_line_counter"
line_found=$find_line_counter
break
fi
done < "$file_path"
if [[ ! "$line_found" == "0" ]] ;then
#Remove the line
sed -i "$line_found d" $file_path
# Add the new line
sed -i "$line_found i $new_string" $file_path
else
echo "ERROR: Target line not found."
sleep 2
fi
else
echo "ERROR: Target file not found."
sleep 2
fi
}
# _writeSettings $settingsFile $customtext
_writeSettings() {
if [ ! -f $1 ] ;then

View File

@ -0,0 +1,2 @@
name="Keyboard"
order=30

View File

@ -0,0 +1,2 @@
#!/bin/bash
_getHeader "$name"

View File

@ -0,0 +1,2 @@
name="Natural Scrolling"
order=1

View File

@ -0,0 +1,31 @@
#!/bin/bash
_getHeader "$name" "$author"
echo "Enable/Disable the natural scrolling for touchpads."
# Define File
targetFile="$HOME/dotfiles/hypr/conf/keyboard.conf"
settingsFile="$HOME/dotfiles/.settings/keyboard_naturalscroll"
# Define Markers
findMarker="natural_scroll"
# Select Value
customvalue=$(gum choose "Enable" "Disable")
if [ ! -z $customvalue ]; then
if [ "$customvalue" == "Enable" ] ;then
customtext=" natural_scroll = true"
else
customtext=" natural_scroll = false"
fi
_replaceLineInFile "$findMarker" "$customtext" "$targetFile"
_writeSettings "$settingsFile" "$customtext"
echo "Keyboard settings changed."
sleep 2
_goBack
else
echo "ERROR: Define a value."
sleep 2
_goBack
fi