def fix_translation_bug(user): cmd = "mkdir -p ~/.local/share/applications/" proc.run_as_user(user, cmd) current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "cp -rf %s/translations/* ~/.local/share/applications/" % ( current_dir) proc.run_as_user(user, cmd)
def install_terminator(user): os.system("pacman -S --noconfirm terminator") current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "mkdir -p ~/.config/terminator/" proc.run_as_user(user, cmd) cmd = "cp -rf %s/../../development/terminator/config ~/.config/terminator/" % ( current_dir) proc.run_as_user(user, cmd)
def do_zsh_config(user): os.system("pacman -S --noconfirm zsh") cmd = "chsh -s $(which zsh) %s" % user os.system(cmd) current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "sh %s/zsh/config.sh" % (current_dir) proc.run_as_user(user, cmd) os.system("rm -rf /etc/zsh/zprofile; touch /etc/zsh/zshenv") file.set_to_file("/etc/zsh/zshenv", 'emulate sh -c "source /etc/profile"')
def install_pyenv(user): # 编译 python 需要 os.system("apt install -y make build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \ libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev" ) current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "python %s/../../development/pyenv/py_init.py" % (current_dir) proc.run_as_user(user, cmd)
def install_terminator(user): os.system("apt install -y terminator") current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "mkdir -p ~/.config/terminator/" proc.run_as_user(user, cmd) cmd = "cp -rf %s/../../development/terminator/config ~/.config/terminator/" % ( current_dir) proc.run_as_user(user, cmd) # 查询 sudo update-alternatives --config x-terminal-emulator os.system( "update-alternatives --set x-terminal-emulator /usr/bin/terminator")
def do_zsh_config(user): os.system("apt install -y zsh") cmd = "chsh -s $(which zsh) %s" % user os.system(cmd) proc.run_as_user(user, cmd) current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "sh %s/zsh/config.sh" % (current_dir) proc.run_as_user(user, cmd) file.set_to_file( "/etc/zsh/zshenv", 'emulate sh -c "source /etc/profile"', need_new_blank_line=True, )
def install_chinese(user): os.system( "apt install -y xfonts-intl-chinese fonts-wqy-microhei fonts-wqy-zenhei xfonts-wqy" ) os.system("apt install -y fcitx5 fcitx5-chinese-addons") current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "mkdir -p ~/.config/fcitx5/" proc.run_as_user(user, cmd) cmd = "cp -rf %s/fcitx/config/* ~/.config/fcitx5/" % (current_dir) proc.run_as_user(user, cmd) cmd = "mkdir -p ~/.local/share/fcitx5/themes/" proc.run_as_user(user, cmd) cmd = "cp -rf %s/fcitx/themes/* ~/.local/share/fcitx5/themes/" % ( current_dir) proc.run_as_user(user, cmd) # user_home_path = os.path.expanduser("~" + user) # profile = user_home_path + "/" + ".profile" # file.set_to_file(profile, "export INPUT_METHOD=fcitx5", need_new_blank_line=True) # file.set_to_file(profile, "export GTK_IM_MODULE=fcitx5") # file.set_to_file(profile, "export QT_IM_MODULE=fcitx5") # file.set_to_file(profile, 'export XMODIFIERS="@im=fcitx5"') os.system("ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime") os.system("dpkg-reconfigure -f noninteractive tzdata") os.system("echo LANG=zh_CN.UTF-8 > /etc/default/locale") os.system("sed -i -e 's/# zh_CN/zh_CN/g' /etc/locale.gen") os.system("dpkg-reconfigure -f noninteractive locales") os.system("update-locale LANG=zh_CN.UTF-8")
def install_themes(user): sudo_ask_pass_info = "export SUDO_ASKPASS=/tmp/pass.sh" install_cmd = "yay -S --noconfirm --sudoflags -A faenza-icon-theme" cmd = "%s; %s" % (sudo_ask_pass_info, install_cmd) proc.run_as_user(user, cmd) proc.run_as_user(user, "mkdir -p ~/.themes") current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "cp -rf %s/themes/* ~/.themes" % (current_dir) proc.run_as_user(user, cmd)
def install_chinese_input(user): os.system( "pacman -S --noconfirm fcitx5 fcitx5-configtool fcitx5-qt fcitx5-gtk fcitx5-chinese-addons fcitx5-material-color" ) current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "mkdir -p ~/.config/fcitx5/" proc.run_as_user(user, cmd) cmd = "cp -rf %s/fcitx/config/* ~/.config/fcitx5/" % (current_dir) proc.run_as_user(user, cmd) cmd = "mkdir -p ~/.local/share/fcitx5/themes/" proc.run_as_user(user, cmd) cmd = "cp -rf %s/fcitx/themes/* ~/.local/share/fcitx5/themes/" % ( current_dir) proc.run_as_user(user, cmd) user_home_path = os.path.expanduser("~" + user) profile = user_home_path + "/" + ".profile" file.set_to_file(profile, "export INPUT_METHOD=fcitx5", need_new_blank_line=True) file.set_to_file(profile, "export GTK_IM_MODULE=fcitx5") file.set_to_file(profile, "export QT_IM_MODULE=fcitx5") file.set_to_file(profile, 'export XMODIFIERS="@im=fcitx5"')
def disable_file_history(user): proc.run_as_user(user, "rm -rf ~/.local/share/recently-used.xbel") proc.run_as_user(user, "mkdir -p ~/.local/share/recently-used.xbel/")
def make_git_default_config(user): os.system("pacman -S --noconfirm git") proc.run_as_user(user, "git config --global core.autocrlf false") proc.run_as_user(user, "git config --global core.quotepath off")
def install_vscode(user): sudo_ask_pass_info = "export SUDO_ASKPASS=/tmp/pass.sh" install_cmd = "yay -S --noconfirm --sudoflags -A visual-studio-code-bin" cmd = "%s; %s" % (sudo_ask_pass_info, install_cmd) proc.run_as_user(user, cmd)
def install_yay(user): os.system("pacman -S --noconfirm yay") proc.run_as_user(user, "yay --sudoloop --save")
def do_vim_config(user): os.system("apt install -y vim-gtk") os.system("rm -rf /usr/share/applications/vim.desktop") current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "sh %s/../../development/vim/install.sh" % (current_dir) proc.run_as_user(user, cmd)
def install_asdf(user): current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "python %s/../../development/asdf/asdf_init.py" % (current_dir) proc.run_as_user(user, cmd)
def englishization_user_dir_name(user): proc.run_as_user(user, "mv ~/桌面 ~/Desktop > /dev/null 2>&1") current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "cp -rf %s/englih_user_dir/user-dirs.dirs ~/.config/" % (current_dir) proc.run_as_user(user, cmd) proc.run_as_user(user, "mkdir -p ~/.templates")
def rm_unused_menu(user): proc.run_as_user(user, "rm -rf ~/.local/share/applications/*.wine")
def install_browser(user): sudo_ask_pass_info = "export SUDO_ASKPASS=/tmp/pass.sh" install_cmd = "yay -S --noconfirm --sudoflags -A google-chrome" cmd = "%s; %s" % (sudo_ask_pass_info, install_cmd) proc.run_as_user(user, cmd)
def install_socket_tool(user): sudo_ask_pass_info = "export SUDO_ASKPASS=/tmp/pass.sh" install_cmd = "yay -S --noconfirm --sudoflags -A sokit" cmd = "%s; %s" % (sudo_ask_pass_info, install_cmd) proc.run_as_user(user, cmd)
def install_embedded_tools(user): sudo_ask_pass_info = "export SUDO_ASKPASS=/tmp/pass.sh" install_cmd = "yay -S --noconfirm --sudoflags -A can-utils" cmd = "%s; %s" % (sudo_ask_pass_info, install_cmd) proc.run_as_user(user, cmd)
def make_git_default_config(user): proc.run_as_user(user, "git config --global core.autocrlf false") proc.run_as_user(user, "git config --global core.quotepath off")
def install_remote_desktop(user): sudo_ask_pass_info = "export SUDO_ASKPASS=/tmp/pass.sh" install_cmd = "yay -S --noconfirm --sudoflags -A anydesk-bin" cmd = "%s; %s" % (sudo_ask_pass_info, install_cmd) proc.run_as_user(user, cmd)
def set_xterm_config(user): current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "cp -rf %s/xterm_config/default.conf ~/.Xdefaults" % (current_dir) proc.run_as_user(user, cmd)
def install_ios_tools(user): sudo_ask_pass_info = "export SUDO_ASKPASS=/tmp/pass.sh" install_cmd = "yay -S --noconfirm --sudoflags -A idevicerestore" cmd = "%s; %s" % (sudo_ask_pass_info, install_cmd) proc.run_as_user(user, cmd)
def install_themes(user): os.system("apt install -y faenza-icon-theme") proc.run_as_user(user, "mkdir -p ~/.themes") current_dir = os.path.dirname(os.path.abspath(__file__)) cmd = "cp -rf %s/themes/* ~/.themes" % (current_dir) proc.run_as_user(user, cmd)
def install_image_viewer(user): sudo_ask_pass_info = "export SUDO_ASKPASS=/tmp/pass.sh" install_cmd = "yay -S --noconfirm --sudoflags -A xnviewmp" cmd = "%s; %s" % (sudo_ask_pass_info, install_cmd) proc.run_as_user(user, cmd)
def init_profile(user): proc.run_as_user(user, "rm -rf ~/.profile") proc.run_as_user(user, "touch ~/.profile")