aboutsummaryrefslogtreecommitdiffstats
path: root/copy.sh
diff options
context:
space:
mode:
authorJaKooLit <jimmielovejay.com>2024-01-01 12:54:29 +0900
committerJaKooLit <jimmielovejay.com>2024-01-01 12:54:29 +0900
commit978cb01c7794ca6aabc613810b23698f94fad298 (patch)
tree46f35f0afd3b7fe0c3fa62f9c567f6163c3d6893 /copy.sh
parent020b2bbc38891bf998f3a7a2d549bcb41a7c3a31 (diff)
adjust copy.sh to use localectl first then setxkbmap next if localectl not available
Introduce wallpaper rofi menu
Diffstat (limited to 'copy.sh')
-rwxr-xr-xcopy.sh34
1 files changed, 9 insertions, 25 deletions
diff --git a/copy.sh b/copy.sh
index 20a1c704..917e5554 100755
--- a/copy.sh
+++ b/copy.sh
@@ -50,25 +50,17 @@ if hostnamectl | grep -q 'Chassis: vm'; then
sed -i '/monitor = Virtual-1, 1920x1080@60,auto,1/s/^#//' config/hypr/UserConfigs/Monitors.conf
fi
-# Preparing hyprland.conf to check for current keyboard layout
-# Function to detect keyboard layout in an X server environment
-detect_x_layout() {
- if command -v setxkbmap >/dev/null 2>&1; then
- layout=$(setxkbmap -query | grep layout | awk '{print $2}')
+# Function to detect keyboard layout using localectl or setxkbmap
+detect_layout() {
+ if command -v localectl >/dev/null 2>&1; then
+ layout=$(localectl status --no-pager | awk '/X11 Layout/ {print $3}')
if [ -n "$layout" ]; then
echo "$layout"
else
echo "unknown"
fi
- else
- echo "unknown"
- fi
-}
-
-# Function to detect keyboard layout in a tty environment
-detect_tty_layout() {
- if command -v localectl >/dev/null 2>&1; then
- layout=$(localectl status --no-pager | awk '/X11 Layout/ {print $3}')
+ elif command -v setxkbmap >/dev/null 2>&1; then
+ layout=$(setxkbmap -query | grep layout | awk '{print $2}')
if [ -n "$layout" ]; then
echo "$layout"
else
@@ -79,22 +71,14 @@ detect_tty_layout() {
fi
}
-# Detect the current keyboard layout based on the environment
-if [ -n "$DISPLAY" ]; then
- # System is in an X server environment
- layout=$(detect_x_layout)
-else
- # System is in a tty environment
- layout=$(detect_tty_layout)
-fi
-
-echo "Keyboard layout: $layout"
+# Detect the current keyboard layout
+layout=$(detect_layout)
printf "${NOTE} Detecting keyboard layout to prepare necessary changes in hyprland.conf before copying\n\n"
# Prompt the user to confirm whether the detected layout is correct
while true; do
- read -p "$ORANGE Detected keyboard layout or keymap: $layout. Is this correct? [y/n] " confirm
+ read -p "$ORANGE Detected current keyboard layout is: $layout. Is this correct? [y/n] " confirm
case $confirm in
[yY])
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage