Skip to content

Disable keyboard with a bind #4283

Closed Answered by muellerbernd
noahfraiture asked this question in Q&A
Discussion options

You must be logged in to vote

Here my current script for laptop keyboard toggle (inspired by this reddit post):

#!/usr/bin/env bash

export STATUS_FILE="$XDG_RUNTIME_DIR/keyboard.status"

enable_keyboard() {
    printf "true" >"$STATUS_FILE"
    notify-send -u normal "Enabling Keyboard"
    hyprctl keyword '$LAPTOP_KB_ENABLED' "true" -r
}

disable_keyboard() {
    printf "false" >"$STATUS_FILE"
    notify-send -u normal "Disabling Keyboard"
    hyprctl keyword '$LAPTOP_KB_ENABLED' "false" -r
}

if ! [ -f "$STATUS_FILE" ]; then
  enable_keyboard
else
  if [ $(cat "$STATUS_FILE") = "true" ]; then
    disable_keyboard
  elif [ $(cat "$STATUS_FILE") = "false" ]; then
    enable_keyboard
  fi
fi

add the following to your h…

Replies: 4 comments 13 replies

Comment options

You must be logged in to vote
10 replies
@vaxerski
Comment options

@muellerbernd
Comment options

@vaxerski
Comment options

@muellerbernd
Comment options

@vaxerski
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by noahfraiture
Comment options

You must be logged in to vote
3 replies
@noahfraiture
Comment options

@vaxerski
Comment options

@jenil1122
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants