No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wifi 724B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. has() {
  3. local verbose=false
  4. if [[ $1 == '-v' ]]; then
  5. verbose=true
  6. shift
  7. fi
  8. for c in "$@"; do c="${c%% *}"
  9. if ! command -v "$c" &> /dev/null; then
  10. [[ "$verbose" == true ]] && err "$c not found"
  11. return 1
  12. fi
  13. done
  14. }
  15. err() {
  16. printf '\e[31m%s\e[0m\n' "$*" >&2
  17. }
  18. die() {
  19. (( $# > 0 )) && err "$*"
  20. exit 1
  21. }
  22. has -v nmcli fzf || die
  23. nmcli -d wifi rescan 2> /dev/null
  24. network=$(nmcli --color yes device wifi | fzf --ansi --height=40% --reverse --cycle --inline-info --header-lines=1)
  25. [[ -z "$network" ]] && exit
  26. network=$(sed -r 's/^\s*\*?\s*//; s/\s*(Ad-Hoc|Infra).*//' <<< "$network")
  27. echo "connecting to \"${network}\"..."
  28. nmcli -a device wifi connect "$network"