<commit_before>#!/usr/bin/env bash

# -----------------------------------------------------------------
# Author : <EMAIL>
# Reference : https://github.com/tracyone/dotfiles/
# Abstract : bootstrap functions
# -----------------------------------------------------------------

# Environment {{{1
[ -z "${REPO_PATH}" ] && REPO_PATH="${HOME}/repos"
[ -z "${CURR_PATH}" ] && CURR_PATH=$(pwd)
[ -z "${GITSRVURL}" ] && GITSRVURL="github.com" # mirror0: github.com.cnpmjs.org(not work)   mirror1: gitee.com(not work)

# Setup Functions {{{1
# -----------------------------------------------------------------
function msg() { # {{{2
    printf '%b\n' "$1" >&2
}

function success() { # {{{2
    if [ "$ret" -eq '0' ]; then
        msg "\33[32m[✔]\33[0m ${1}${2}"
    fi
}

function lnif() {
    if [ -e "$1" ]; then
        ln -sfT "$1" "$2"
    fi
    ret="$?"
    debug
}

function pkg_install() { # {{{2
  sudo dnf install -y $1
}

function rocky_mirror() { # {{{2
  read -n1 -p "yum.repos mirror ? (y/N) " ans
  if [[ $ans =~ [Yy] ]]; then
    # sudo dnf remove -y epel-release
    sudo dnf clean all
    sudo rm -rf /var/cache/dnf /var/cache/yum

    sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
             -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.sjtug.sjtu.edu.cn/rocky|g' \
             -i.bak \
             /etc/yum.repos.d/Rocky-*.repo

    sudo dnf install -y epel-release
    sudo sed -e 's|^metalink=|#metalink=|g' \
             -e 's|^#baseurl=https://download.example/pub|baseurl=https://mirror.sjtu.edu.cn/fedora|g' \
             -i.bak \
             /etc/yum.repos.d/epel*.repo

    sudo dnf makecache
    sudo dnf -y update
    # sudo dnf -y upgrade

    sudo rm -f /tmp/yum_save_tx* # clean log
  else
    printf '\n' >&2
  fi
}

function rocky_xinput() { # {{{2
  sudo mkdir -p /etc/X11/xinit/xinput.d/
  lnif "${REPO_PATH}/dotfiles.git/linux/fcitx.conf"   "/etc/X11/xinit/xinput.d/fcitx.conf"
  lnif "/etc/X11/xinit/xinput.d/fcitx.conf"   "/etc/X11/xinit/xinput.d/none.conf"
  sudo update-alternatives --install /etc/X11/xinit/xinputrc xinputrc /etc/X11/xinit/xinput.d/fcitx.conf 1
  sudo update-alternatives --set xinputrc /etc/X11/xinit/xinput.d/fcitx.conf

  # 而ibus会造成fcitx无法正常启动, so we remove ibus first
  pkg_install "im-chooser imsettings-gsettings" # imsettings-xim" # input method setting
  pkg_install "gtk3-immodules gtk3-immodule-xim" # input method

  # pkg_install "ibus-libpinyin ibus-table-chinese-wubi-jidian"
  # pkg_install "ibus ibus-qt ibus-gtk2 ibus-gtk3 ibus-table-chinese-wubi-jidian" # ibus
  # ibus-setup # config ibus
  # imsettings-switch ibus
  # im-chooser

  pkg_install "fcitx fcitx-table-chinese" # fcitx
  # pkg_install "fcitx fcitx-qt5 fcitx-configtool fcitx-table-chinese" # fcitx
}

function rocky_dwm() { # {{{2
  pkg_install 'xorg-x11-server-Xorg xorg-x11-xauth xorg-x11-xinit xdg-desktop-portal xsetroot'
  pkg_install 'xorg-x11-proto-devel libX11-devel libXft-devel libXinerama-devel libXinerama-devel'
  pkg_install 'network-manager-applet xfce4-power-manager' # NetworkManager 
  # xbacklight TODO

  # sddm lightdm gdm(gnome)
  # sudo systemctl set-default multi-user.target # command login
  sudo systemctl set-default graphical.target # ui login
  # # https://netsarang.atlassian.net/wiki/spaces/ENSUP/pages/326697004/RHEL+8.x+XDMCP+Configuration+RHEL+8.0+RHEL+8.1
  pkg_install "${REPO_PATH}/dotfiles.git/linux/lightdm-gtk-common-1.8.5-19.el7.noarch.rpm"
  pkg_install "${REPO_PATH}/dotfiles.git/linux/lightdm-gtk-1.8.5-19.el7.x86_64.rpm"<commit_msg>volumn<commit_after>#!/usr/bin/env bash

# -----------------------------------------------------------------
# Author : <EMAIL>
# Reference : https://github.com/tracyone/dotfiles/
# Abstract : bootstrap functions
# -----------------------------------------------------------------

# Environment {{{1
[ -z "${REPO_PATH}" ] && REPO_PATH="${HOME}/repos"
[ -z "${CURR_PATH}" ] && CURR_PATH=$(pwd)
[ -z "${GITSRVURL}" ] && GITSRVURL="github.com" # mirror0: github.com.cnpmjs.org(not work)   mirror1: gitee.com(not work)

# Setup Functions {{{1
# -----------------------------------------------------------------
function msg() { # {{{2
    printf '%b\n' "$1" >&2
}

function success() { # {{{2
    if [ "$ret" -eq '0' ]; then
        msg "\33[32m[✔]\33[0m ${1}${2}"
    fi
}

function lnif() {
    if [ -e "$1" ]; then
        ln -sfT "$1" "$2"
    fi
    ret="$?"
    debug
}

function pkg_install() { # {{{2
  sudo dnf install -y $1
}

function rocky_mirror() { # {{{2
  read -n1 -p "yum.repos mirror ? (y/N) " ans
  if [[ $ans =~ [Yy] ]]; then
    # sudo dnf remove -y epel-release
    sudo dnf clean all
    sudo rm -rf /var/cache/dnf /var/cache/yum

    sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
             -e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=https://mirrors.sjtug.sjtu.edu.cn/rocky|g' \
             -i.bak \
             /etc/yum.repos.d/Rocky-*.repo

    sudo dnf install -y epel-release
    sudo sed -e 's|^metalink=|#metalink=|g' \
             -e 's|^#baseurl=https://download.example/pub|baseurl=https://mirror.sjtu.edu.cn/fedora|g' \
             -i.bak \
             /etc/yum.repos.d/epel*.repo

    sudo dnf makecache
    sudo dnf -y update
    # sudo dnf -y upgrade

    sudo rm -f /tmp/yum_save_tx* # clean log
  else
    printf '\n' >&2
  fi
}

function rocky_xinput() { # {{{2
  sudo mkdir -p /etc/X11/xinit/xinput.d/
  lnif "${REPO_PATH}/dotfiles.git/linux/fcitx.conf"   "/etc/X11/xinit/xinput.d/fcitx.conf"
  lnif "/etc/X11/xinit/xinput.d/fcitx.conf"   "/etc/X11/xinit/xinput.d/none.conf"
  sudo update-alternatives --install /etc/X11/xinit/xinputrc xinputrc /etc/X11/xinit/xinput.d/fcitx.conf 1
  sudo update-alternatives --set xinputrc /etc/X11/xinit/xinput.d/fcitx.conf

  # 而ibus会造成fcitx无法正常启动, so we remove ibus first
  pkg_install "im-chooser imsettings-gsettings" # imsettings-xim" # input method setting
  pkg_install "gtk3-immodules gtk3-immodule-xim" # input method

  # pkg_install "ibus-libpinyin ibus-table-chinese-wubi-jidian"
  # pkg_install "ibus ibus-qt ibus-gtk2 ibus-gtk3 ibus-table-chinese-wubi-jidian" # ibus
  # ibus-setup # config ibus
  # imsettings-switch ibus
  # im-chooser

  pkg_install "fcitx fcitx-table-chinese" # fcitx
  # pkg_install "fcitx fcitx-qt5 fcitx-configtool fcitx-table-chinese" # fcitx
}

function rocky_dwm() { # {{{2
  pkg_install 'xorg-x11-server-Xorg xorg-x11-xauth xorg-x11-xinit xdg-desktop-portal xsetroot'
  pkg_install 'xorg-x11-proto-devel libX11-devel libXft-devel libXinerama-devel libXinerama-devel'
  pkg_install 'network-manager-applet xfce4-power-manager xfce4-volumed-pulse' # NetworkManager
  # xbacklight TODO

  # sddm lightdm gdm(gnome)
  # sudo systemctl set-default multi-user.target # command login
  sudo systemctl set-default graphical.target # ui login
  # # https://netsarang.atlassian.net/wiki/spaces/ENSUP/pages/326697004/RHEL+8.x+XDMCP+Configuration+RHEL+8.0+RHEL+8.1
  pkg_install "${REPO_PATH}/dotfiles.git/linux/lightdm-gtk-common-1.8.5-19.el7.noarch.rpm"
  pkg_install "${REPO_PATH}/dotfiles.git/linux/lightdm-gtk-1.8.5-19.el7.x86_64.rpm"
{'fraction_non_alphanumeric': 0.20977253580454927, 'fraction_numerical': 0.02513338949733221, 'mean_word_length': 2.4899559039686427, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3340469', 'n_tokens_mistral': 2997, 'n_tokens_neox': 2790, 'n_words': 500}