From 008dff29aaebba67105c52a610c1d9911eff0220 Mon Sep 17 00:00:00 2001 From: clsty Date: Wed, 3 Jan 2024 21:48:35 +0800 Subject: [PATCH 01/10] Enable custom domain for openai api url --- .config/ags/services/chatgpt.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.config/ags/services/chatgpt.js b/.config/ags/services/chatgpt.js index b50892235..19aa23e64 100644 --- a/.config/ags/services/chatgpt.js +++ b/.config/ags/services/chatgpt.js @@ -45,6 +45,16 @@ function expandTilde(path) { // We're using many models to not be restricted to 3 messages per minute. // The whole chat will be sent every request anyway. const KEY_FILE_LOCATION = `${GLib.get_user_cache_dir()}/ags/user/openai_api_key.txt`; +const APIDOM_FILE_LOCATION = `${GLib.get_user_cache_dir()}/ags/user/openai_api_dom.txt`; +function replaceapidom(URL) { + //Utils.writeFile(URL, "/tmp/openai-url-old.log"); // For debugging + if (fileExists(expandTilde(APIDOM_FILE_LOCATION))) { + var contents = Utils.readFile(expandTilde(APIDOM_FILE_LOCATION)).trim(); + var URL = URL.toString().replace("api.openai.com", contents); + } + //Utils.writeFile(URL, "/tmp/openai-url.log"); // For debugging + return URL; +} const CHAT_MODELS = ["gpt-3.5-turbo-1106", "gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-0613"] const ONE_CYCLE_COUNT = 3; @@ -126,7 +136,8 @@ class ChatGPTService extends Service { _modelIndex = 0; _key = ''; _decoder = new TextDecoder(); - url = GLib.Uri.parse('https://api.openai.com/v1/chat/completions', GLib.UriFlags.NONE); + + url = GLib.Uri.parse(replaceapidom('https://api.openai.com/v1/chat/completions'), GLib.UriFlags.NONE); constructor() { super(); From 804a86f8b7f82025b2d62d9af2b132e0254e1eb8 Mon Sep 17 00:00:00 2001 From: clsty Date: Wed, 3 Jan 2024 21:49:22 +0800 Subject: [PATCH 02/10] Improvements on install.sh --- install.sh | 57 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 17 deletions(-) diff --git a/install.sh b/install.sh index e9ff41f65..40291770b 100755 --- a/install.sh +++ b/install.sh @@ -4,23 +4,23 @@ export base="$(pwd)" function try { "$@" || sleep 0; } function v() { - echo -e "[$0]: \e[34mNow executing:\e[0m" + echo -e "\e[34m[$0]: Next command to be executed:\e[0m" echo -e "\e[32m$@\e[0m" execute=true if $ask;then while true;do - echo -e "\e[34mDo you want to execute this command? \e[0m" + echo -e "\e[34mDo you want to execute the command shown above? \e[0m" echo " y = Yes" - echo " a = Abort this script" + echo " e = Exit now" echo " s = Skip this command; NOT recommended unless you really sure" echo " yesforall = yes and don't ask again; NOT recommended unless you really sure" - read -p "Enter here [y/a/s/yesforall]:" p + read -p "Enter here [y/e/s/yesforall]:" p case $p in [yY]) echo -e "\e[34mOK, executing...\e[0m" ;break ;; - [aA]) echo -e "\e[34mAborting...\e[0m" ;exit ;break ;; + [eE]) echo -e "\e[34mExiting...\e[0m" ;exit ;break ;; [sS]) echo -e "\e[34mAlright, skipping this one...\e[0m" ;export execute=false ;break ;; "yesforall") echo -e "\e[34mAlright, won't ask again. Executing...\e[0m"; export ask=false ;break ;; - *) echo -e "\e[31mPlease enter one of [y/a/s/yesforall].\e[0m";; + *) echo -e "\e[31mPlease enter one of [y/e/s/yesforall].\e[0m";; esac done fi @@ -29,26 +29,49 @@ function v() { fi } ##################################################################################### -printf "[$0]: Hi there!\n" +startask (){ +printf "\e[34m[$0]: Hi there!\n" printf 'This script 1. only works for ArchLinux and Arch-based distros.\n' printf ' 2. has not been fully tested, use at your own risk.\n' -printf "\e[36m== PLEASE BACKUP \"$HOME/.config\" AND \"$HOME/.local\" BY YOURSELF IF NEEDED! ==\n\e[97m" +printf '\n' +printf "\e[31m" +printf "=============\n" +printf "PLEASE CONFIRM\n" +printf "YOU HAVE\n" +printf " \"$HOME/.config\"\n" +printf " AND\n" +printf " \"$HOME/.local\"\n" +printf "ALREADY BACKUPED\n" +printf "BY YOURSELF!\n" +printf "=============\n" +printf "\n\e[97m" +printf "Enter the capital \"YES\" to continue:" +read -p " " p +case $p in "YES")sleep 0;; *)exit;;esac printf '\n' printf 'Do you want to confirm everytime before a command executes?\n' printf ' y = Yes, ask me before executing each of them. (RECOMMENDED)\n' printf ' n = No, just execute them automatically.\n' -printf ' E = Exit this script. (DEFAULT)\n' -read -p "Enter y/n/E: " p +printf ' a = Abort. (DEFAULT)\n' +read -p "Enter [y/n/A]: " p case $p in y)export ask=true;; - n)export ask=false; export c=" --noconfirm" ;; + n)export ask=false; export noconfirm=" --noconfirm" ;; *)exit;; esac +} + +case $1 in + "-f")export ask=false; export noconfirm=" --noconfirm" ;; + *)startask ;; +esac + set -e ##################################################################################### printf '\e[36m1. Get packages and add user to video/input groups\n\e[97m' -v yay -S --needed$c blueberry brightnessctl coreutils curl fish foot fuzzel gjs gnome-bluetooth-3.0 gnome-control-center gnome-keyring gobject-introspection grim gtk3 gtk-layer-shell libdbusmenu-gtk3 meson networkmanager npm plasma-browser-integration playerctl polkit-gnome python-pywal ripgrep sassc slurp starship swayidle typescript upower xorg-xrandr webp-pixbuf-loader wget wireplumber wl-clipboard tesseract yad ydotool adw-gtk3-git cava gojq gradience-git gtklock gtklock-playerctl-module gtklock-powerbar-module gtklock-userinfo-module hyprland-git lexend-fonts-git python-material-color-utilities python-pywal python-poetry python-build python-pillow swaylock-effects-git swww ttf-material-symbols-variable-git ttf-space-mono-nerd ttf-jetbrains-mono-nerd wayland-idle-inhibitor-git wlogout wlsunset-git hyprpicker-git rsync +v yay -S --needed$noconfirm blueberry brightnessctl coreutils curl fish foot fuzzel gjs gnome-bluetooth-3.0 gnome-control-center gnome-keyring gobject-introspection grim gtk3 gtk-layer-shell libdbusmenu-gtk3 meson networkmanager npm plasma-browser-integration playerctl polkit-gnome python-pywal ripgrep sassc slurp starship swayidle typescript upower xorg-xrandr webp-pixbuf-loader wget wireplumber wl-clipboard tesseract yad ydotool adw-gtk3-git cava gojq gradience-git gtklock gtklock-playerctl-module gtklock-powerbar-module gtklock-userinfo-module hyprland-git lexend-fonts-git python-material-color-utilities python-pywal python-poetry python-build python-pillow swaylock-effects-git swww ttf-material-symbols-variable-git ttf-space-mono-nerd ttf-jetbrains-mono-nerd wayland-idle-inhibitor-git wlogout wlsunset-git hyprpicker-git rsync +# NOTE: wayland-idle-inhibitor-git is for providing `wayland-idle-inhibitor.py' used by the `Keep system awake' button in `.config/ags/widgets/sideright/quicktoggles.js'. v sudo usermod -aG video "$(whoami)" v sudo usermod -aG input "$(whoami)" @@ -71,7 +94,7 @@ installags (){ cd $base } if command -v ags >/dev/null 2>&1 - then echo -e "\e[34mCommand \"ags\" already exists. Won't install ags.\e[0m" + then echo -e "\e[34mCommand \"ags\" already exists. Won\'t install ags.\e[0m" else installags fi @@ -79,7 +102,7 @@ fi printf '\e[36m3. Copying\e[97m\n' # In case ~/.local/bin does not exists -v mkdir -p "$HOME/.local/bin" +v mkdir -p "$HOME/.local/bin" "$HOME/.local/share" # `--delete' for rsync to make sure that # original dot files and new ones in the SAME DIRECTORY @@ -93,11 +116,11 @@ do fi done -# .local/bin should be processed seperately to avoid `--delete' for rsync, -# since the files here comes from different places, not only one program. +# some foldes (eg. .local/bin) should be processed seperately to avoid `--delete' for rsync, +# since the files here come from different places, not only about one program. v rsync -av ".local/bin/" "$HOME/.local/bin/" ##################################################################################### -printf "[$0]: \e[36mFinished. See the \"Import Manually\" folder and grab anything you need.\e[97m\n" +printf "\e[36m[$0]: Finished. See the \"Import Manually\" folder and grab anything you need.\e[97m\n" printf "\e[36mPress \e[30m\e[46m Ctrl+Super+T \e[0m\e[36m to select a wallpaper\e[97m\n" printf "\e[36mPress \e[30m\e[46m Super+/ \e[0m\e[36m for a list of keybinds\e[97m\n" From 03e26d7768611d518662c36c2bbe2e8417da40a2 Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 4 Jan 2024 07:55:41 +0800 Subject: [PATCH 03/10] Remove execute permission for non-executables --- .config/ags/scss/_colors.scss | 0 .config/ags/scss/_dock.scss | 0 .config/ags/scss/_material.scss | 0 .config/ags/scss/_musicmaterial.scss | 0 4 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 .config/ags/scss/_colors.scss mode change 100755 => 100644 .config/ags/scss/_dock.scss mode change 100755 => 100644 .config/ags/scss/_material.scss mode change 100755 => 100644 .config/ags/scss/_musicmaterial.scss diff --git a/.config/ags/scss/_colors.scss b/.config/ags/scss/_colors.scss old mode 100755 new mode 100644 diff --git a/.config/ags/scss/_dock.scss b/.config/ags/scss/_dock.scss old mode 100755 new mode 100644 diff --git a/.config/ags/scss/_material.scss b/.config/ags/scss/_material.scss old mode 100755 new mode 100644 diff --git a/.config/ags/scss/_musicmaterial.scss b/.config/ags/scss/_musicmaterial.scss old mode 100755 new mode 100644 From 719c223821b7e3d6153d26a347d6bc9a5938eaaf Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 4 Jan 2024 08:00:19 +0800 Subject: [PATCH 04/10] Remove duplicated entry in .gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index b69e763b8..080a2b5e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ .config/ags/style.css -.config/hypr/colors.conf .config/ags/scripts/templates/gradience/preset.json .config/ags/scss/_musicmaterial.scss .config/ags/style.css -.config/hypr/colors.conf .config/ags/scss/_material.scss +.config/hypr/colors.conf /ags From e1fba5699c3fdf89dd1d07b870b4faca2029a3f4 Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 4 Jan 2024 09:13:38 +0800 Subject: [PATCH 05/10] Read dependencies from a file. --- dependencies.txt | 14 ++++++++++++++ install.sh | 15 +++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 dependencies.txt diff --git a/dependencies.txt b/dependencies.txt new file mode 100644 index 000000000..fc1cf0216 --- /dev/null +++ b/dependencies.txt @@ -0,0 +1,14 @@ +coreutils curl rsync wget ripgrep gojq npm meson typescript gjs sassc +python-build python-material-color-utilities python-pillow python-poetry python-pywal +hyprland-git xorg-xrandr +cava pavucontrol wireplumber libdbusmenu-gtk3 plasma-browser-integration playerctl +webp-pixbuf-loader gtk-layer-shell gtk3 gobject-introspection upower +fuzzel yad ydotool +gtklock gtklock-playerctl-module gtklock-powerbar-module gtklock-userinfo-module +polkit-gnome gnome-keyring gnome-control-center +blueberry networkmanager brightnessctl wlsunset-git gnome-bluetooth-3.0 +wayland-idle-inhibitor-git swayidle swaylock-effects-git wlogout +wl-clipboard hyprpicker-git grim tesseract slurp +adw-gtk3-git gradience-git swww +lexend-fonts-git ttf-jetbrains-mono-nerd ttf-material-symbols-variable-git ttf-space-mono-nerd +fish foot starship diff --git a/install.sh b/install.sh index 40291770b..d783f59ea 100755 --- a/install.sh +++ b/install.sh @@ -12,7 +12,7 @@ function v() { echo -e "\e[34mDo you want to execute the command shown above? \e[0m" echo " y = Yes" echo " e = Exit now" - echo " s = Skip this command; NOT recommended unless you really sure" + echo " s = Skip this command; NOT recommended (may break functions needed by the dot files!)" echo " yesforall = yes and don't ask again; NOT recommended unless you really sure" read -p "Enter here [y/e/s/yesforall]:" p case $p in @@ -56,23 +56,30 @@ printf ' a = Abort. (DEFAULT)\n' read -p "Enter [y/n/A]: " p case $p in y)export ask=true;; - n)export ask=false; export noconfirm=" --noconfirm" ;; + n)export ask=false;; *)exit;; esac } case $1 in - "-f")export ask=false; export noconfirm=" --noconfirm" ;; + "-f")export ask=false;; *)startask ;; esac set -e +IFS_old=$IFS ##################################################################################### printf '\e[36m1. Get packages and add user to video/input groups\n\e[97m' -v yay -S --needed$noconfirm blueberry brightnessctl coreutils curl fish foot fuzzel gjs gnome-bluetooth-3.0 gnome-control-center gnome-keyring gobject-introspection grim gtk3 gtk-layer-shell libdbusmenu-gtk3 meson networkmanager npm plasma-browser-integration playerctl polkit-gnome python-pywal ripgrep sassc slurp starship swayidle typescript upower xorg-xrandr webp-pixbuf-loader wget wireplumber wl-clipboard tesseract yad ydotool adw-gtk3-git cava gojq gradience-git gtklock gtklock-playerctl-module gtklock-powerbar-module gtklock-userinfo-module hyprland-git lexend-fonts-git python-material-color-utilities python-pywal python-poetry python-build python-pillow swaylock-effects-git swww ttf-material-symbols-variable-git ttf-space-mono-nerd ttf-jetbrains-mono-nerd wayland-idle-inhibitor-git wlogout wlsunset-git hyprpicker-git rsync +readarray -t pkglist < dependencies.txt # NOTE: wayland-idle-inhibitor-git is for providing `wayland-idle-inhibitor.py' used by the `Keep system awake' button in `.config/ags/widgets/sideright/quicktoggles.js'. +if $ask;then + for i in "${pkglist[@]}";do v yay -S --needed $i;done +else + v yay -S --needed --noconfirm "${pkglist[*]}" +fi + v sudo usermod -aG video "$(whoami)" v sudo usermod -aG input "$(whoami)" From 48c66b4bdaad3c57e8b9966c749e1d4fd93ddd61 Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 4 Jan 2024 09:35:38 +0800 Subject: [PATCH 06/10] Add comments. --- install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install.sh b/install.sh index d783f59ea..4b6bfda00 100755 --- a/install.sh +++ b/install.sh @@ -71,12 +71,15 @@ IFS_old=$IFS ##################################################################################### printf '\e[36m1. Get packages and add user to video/input groups\n\e[97m' +# Each line as an element of the array $pkglist readarray -t pkglist < dependencies.txt # NOTE: wayland-idle-inhibitor-git is for providing `wayland-idle-inhibitor.py' used by the `Keep system awake' button in `.config/ags/widgets/sideright/quicktoggles.js'. if $ask;then + # execute per element of the array $pkglist for i in "${pkglist[@]}";do v yay -S --needed $i;done else + # execute for all elements of the array $pkglist in one line v yay -S --needed --noconfirm "${pkglist[*]}" fi From 7efd084eb47c54954e378eb8588364499f904ee8 Mon Sep 17 00:00:00 2001 From: clsty Date: Thu, 4 Jan 2024 09:59:11 +0800 Subject: [PATCH 07/10] Remove unused line. --- install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install.sh b/install.sh index 4b6bfda00..7e3fbc542 100755 --- a/install.sh +++ b/install.sh @@ -67,7 +67,6 @@ case $1 in esac set -e -IFS_old=$IFS ##################################################################################### printf '\e[36m1. Get packages and add user to video/input groups\n\e[97m' From f3b179ea162243cac5964701b1badddfa271d865 Mon Sep 17 00:00:00 2001 From: clsty Date: Fri, 5 Jan 2024 06:43:46 +0800 Subject: [PATCH 08/10] Minor fixes on text. --- install.sh | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/install.sh b/install.sh index 7e3fbc542..6facf423b 100755 --- a/install.sh +++ b/install.sh @@ -12,7 +12,7 @@ function v() { echo -e "\e[34mDo you want to execute the command shown above? \e[0m" echo " y = Yes" echo " e = Exit now" - echo " s = Skip this command; NOT recommended (may break functions needed by the dot files!)" + echo " s = Skip this command; NOT recommended (may break functions needed by the dotfiles!)" echo " yesforall = yes and don't ask again; NOT recommended unless you really sure" read -p "Enter here [y/e/s/yesforall]:" p case $p in @@ -33,19 +33,10 @@ startask (){ printf "\e[34m[$0]: Hi there!\n" printf 'This script 1. only works for ArchLinux and Arch-based distros.\n' printf ' 2. has not been fully tested, use at your own risk.\n' -printf '\n' printf "\e[31m" -printf "=============\n" -printf "PLEASE CONFIRM\n" -printf "YOU HAVE\n" -printf " \"$HOME/.config\"\n" -printf " AND\n" -printf " \"$HOME/.local\"\n" -printf "ALREADY BACKUPED\n" -printf "BY YOURSELF!\n" -printf "=============\n" -printf "\n\e[97m" -printf "Enter the capital \"YES\" to continue:" +printf "Please CONFIRM that you HAVE ALREADY BACKED UP \"$HOME/.config/\" and \"$HOME/.local/\"\n folders!\n" +printf "\e[97m" +printf "Enter the capital \"YES\" (without quotes) to continue: " read -p " " p case $p in "YES")sleep 0;; *)exit;;esac printf '\n' @@ -114,7 +105,7 @@ printf '\e[36m3. Copying\e[97m\n' v mkdir -p "$HOME/.local/bin" "$HOME/.local/share" # `--delete' for rsync to make sure that -# original dot files and new ones in the SAME DIRECTORY +# original dotfiles and new ones in the SAME DIRECTORY # (eg. in ~/.config/hypr) won't be mixed together for i in .config/* From f8631ae087ae5069ff6851e52a90e2a3c15fa8d6 Mon Sep 17 00:00:00 2001 From: clsty Date: Fri, 5 Jan 2024 06:45:19 +0800 Subject: [PATCH 09/10] Minor typo fix. --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 6facf423b..d2b3064b4 100755 --- a/install.sh +++ b/install.sh @@ -34,7 +34,7 @@ printf "\e[34m[$0]: Hi there!\n" printf 'This script 1. only works for ArchLinux and Arch-based distros.\n' printf ' 2. has not been fully tested, use at your own risk.\n' printf "\e[31m" -printf "Please CONFIRM that you HAVE ALREADY BACKED UP \"$HOME/.config/\" and \"$HOME/.local/\"\n folders!\n" +printf "Please CONFIRM that you HAVE ALREADY BACKED UP \"$HOME/.config/\" and \"$HOME/.local/\" folders!\n" printf "\e[97m" printf "Enter the capital \"YES\" (without quotes) to continue: " read -p " " p From 20892e9df1acd03f19dcc46c442cf36f883acaa5 Mon Sep 17 00:00:00 2001 From: clsty Date: Fri, 5 Jan 2024 06:47:25 +0800 Subject: [PATCH 10/10] Minor typo fix. --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index d2b3064b4..3b80e7720 100755 --- a/install.sh +++ b/install.sh @@ -36,7 +36,7 @@ printf ' 2. has not been fully tested, use at your own risk.\n' printf "\e[31m" printf "Please CONFIRM that you HAVE ALREADY BACKED UP \"$HOME/.config/\" and \"$HOME/.local/\" folders!\n" printf "\e[97m" -printf "Enter the capital \"YES\" (without quotes) to continue: " +printf "Enter capital \"YES\" (without quotes) to continue: " read -p " " p case $p in "YES")sleep 0;; *)exit;;esac printf '\n'