dots

git clone git://mattcarlson.org/repos/dots.git
Log | Files | Refs

hosts.sh (651B)


      1 #!/bin/sh
      2 #
      3 # hosts
      4 
      5 HOSTS_DIR="${HOME}/.local/share/"
      6 
      7 enable() { mv "${HOSTS_DIR}hosts.bak" "${HOSTS_DIR}hosts" && env HERBE_ID=/0 herbe 'Hosts enabled' & }
      8 
      9 disable() { mv "${HOSTS_DIR}hosts" "${HOSTS_DIR}hosts.bak" && env HERBE_ID=/0 herbe 'Hosts disabled' & }
     10 
     11 main() {
     12     # in each of the following cases we want to sleep to prevent xcb unknown sequence number error
     13 
     14     # disable by moving hosts to xdg share directory
     15     [ -f "${HOSTS_DIR}/hosts" ]  && disable && sleep 1 && return 0
     16 
     17     # enable by moving hosts to /etc/
     18     # shellcheck disable=SC3044
     19     [ -f "${HOSTS_DIR}/hosts.bak" ] && enable  && sleep 1 && return 0
     20 }
     21 
     22 main "${@}"