Add Keyboard module
This commit is contained in:
parent
2dd04cba6c
commit
ee8a6c6b51
|
@ -230,3 +230,46 @@ _replaceInFile() {
|
||||||
sleep 2
|
sleep 2
|
||||||
fi
|
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
|
||||||
|
}
|
|
@ -269,5 +269,15 @@ echo -e "${NONE}"
|
||||||
echo "nm-applet restored."
|
echo "nm-applet restored."
|
||||||
fi
|
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 ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -3,7 +3,8 @@ https://gitlab.com/stephan-raabe/dotfiles/-/releases/2.7.1
|
||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
Hyprland:
|
Hyprland:
|
||||||
- Add optional network-manager applet support. Can be activated in Settings script System/nm-applet
|
- 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
|
Version 2.7
|
||||||
https://gitlab.com/stephan-raabe/dotfiles/-/releases/2.7
|
https://gitlab.com/stephan-raabe/dotfiles/-/releases/2.7
|
||||||
|
|
|
@ -265,6 +265,49 @@ _replaceInFile() {
|
||||||
fi
|
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 $settingsFile $customtext
|
||||||
_writeSettings() {
|
_writeSettings() {
|
||||||
if [ ! -f $1 ] ;then
|
if [ ! -f $1 ] ;then
|
||||||
|
|
2
hypr/settings/modules/system/keyboard/config.sh
Normal file
2
hypr/settings/modules/system/keyboard/config.sh
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
name="Keyboard"
|
||||||
|
order=30
|
2
hypr/settings/modules/system/keyboard/module.sh
Executable file
2
hypr/settings/modules/system/keyboard/module.sh
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
_getHeader "$name"
|
|
@ -0,0 +1,2 @@
|
||||||
|
name="Natural Scrolling"
|
||||||
|
order=1
|
31
hypr/settings/modules/system/keyboard/naturalscroll/module.sh
Executable file
31
hypr/settings/modules/system/keyboard/naturalscroll/module.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user