From bb28c9089c14facf524737bf46de070a046956e1 Mon Sep 17 00:00:00 2001
From: end-4 <97237370+end-4@users.noreply.github.com>
Date: Wed, 14 Feb 2024 21:11:34 +0700
Subject: [PATCH] sidebar: quick scripts; fix Icon condition race
---
.config/ags/assets/arch-symbolic.svg | 113 ++++++++
.config/ags/assets/debian-symbolic.svg | 91 +++++++
.config/ags/assets/fedora-symbolic.svg | 38 +++
.config/ags/assets/flatpak-symbolic.svg | 52 ++++
.config/ags/assets/nixos-symbolic.svg | 77 ++++++
.config/ags/assets/ubuntu-symbolic.svg | 85 ++++++
.config/ags/lib/notification.js | 6 -
.../quickscripts/nixos-trim-generations.sh | 243 ++++++++++++++++++
.../scripts/templates/gradience/preset.json | 30 +--
.config/ags/scss/_bar.scss | 1 +
.config/ags/scss/_dock.scss | 1 +
.config/ags/scss/_material.scss | 46 ++--
.config/ags/scss/_notifications.scss | 1 +
.config/ags/scss/_sidebars.scss | 24 +-
.config/ags/services/chatgpt.js | 2 +-
.config/ags/services/gemini.js | 2 +-
.config/ags/widgets/bar/tray.js | 11 +-
.config/ags/widgets/dock/dock.js | 6 -
.config/ags/widgets/overview/searchbuttons.js | 12 -
.config/ags/widgets/overview/windowcontent.js | 4 +-
.../widgets/sideleft/apis/ai_chatmessage.js | 3 +-
.config/ags/widgets/sideleft/apis/chatgpt.js | 16 --
.config/ags/widgets/sideleft/apis/gemini.js | 12 -
.config/ags/widgets/sideleft/module.js | 57 ++--
.config/ags/widgets/sideleft/quickscripts.js | 88 ++++++-
.config/ags/widgets/sideleft/toolbox.js | 2 +-
26 files changed, 895 insertions(+), 128 deletions(-)
create mode 100644 .config/ags/assets/arch-symbolic.svg
create mode 100644 .config/ags/assets/debian-symbolic.svg
create mode 100644 .config/ags/assets/fedora-symbolic.svg
create mode 100644 .config/ags/assets/flatpak-symbolic.svg
create mode 100644 .config/ags/assets/nixos-symbolic.svg
create mode 100644 .config/ags/assets/ubuntu-symbolic.svg
create mode 100755 .config/ags/scripts/quickscripts/nixos-trim-generations.sh
diff --git a/.config/ags/assets/arch-symbolic.svg b/.config/ags/assets/arch-symbolic.svg
new file mode 100644
index 000000000..7de9094e0
--- /dev/null
+++ b/.config/ags/assets/arch-symbolic.svg
@@ -0,0 +1,113 @@
+
+
+
+
diff --git a/.config/ags/assets/debian-symbolic.svg b/.config/ags/assets/debian-symbolic.svg
new file mode 100644
index 000000000..252f85334
--- /dev/null
+++ b/.config/ags/assets/debian-symbolic.svg
@@ -0,0 +1,91 @@
+
+
+
+
diff --git a/.config/ags/assets/fedora-symbolic.svg b/.config/ags/assets/fedora-symbolic.svg
new file mode 100644
index 000000000..1a4e8c873
--- /dev/null
+++ b/.config/ags/assets/fedora-symbolic.svg
@@ -0,0 +1,38 @@
+
+
diff --git a/.config/ags/assets/flatpak-symbolic.svg b/.config/ags/assets/flatpak-symbolic.svg
new file mode 100644
index 000000000..0c2bf6280
--- /dev/null
+++ b/.config/ags/assets/flatpak-symbolic.svg
@@ -0,0 +1,52 @@
+
+
diff --git a/.config/ags/assets/nixos-symbolic.svg b/.config/ags/assets/nixos-symbolic.svg
new file mode 100644
index 000000000..b697b0d1a
--- /dev/null
+++ b/.config/ags/assets/nixos-symbolic.svg
@@ -0,0 +1,77 @@
+
+
diff --git a/.config/ags/assets/ubuntu-symbolic.svg b/.config/ags/assets/ubuntu-symbolic.svg
new file mode 100644
index 000000000..07746c9f6
--- /dev/null
+++ b/.config/ags/assets/ubuntu-symbolic.svg
@@ -0,0 +1,85 @@
+
+
+
+
diff --git a/.config/ags/lib/notification.js b/.config/ags/lib/notification.js
index 628b01177..47f2c2061 100644
--- a/.config/ags/lib/notification.js
+++ b/.config/ags/lib/notification.js
@@ -56,12 +56,6 @@ const NotificationIcon = (notifObject) => {
Icon({
vpack: 'center',
icon: icon,
- setup: (self) => Utils.timeout(1, () => {
- const styleContext = self.get_parent().get_style_context();
- const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
- const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
- self.size = Math.max(width * 0.7, height * 0.7, 1); // im too lazy to add another box lol
- }, self),
})
:
MaterialIcon(`${notifObject.urgency == 'critical' ? 'release_alert' : guessMessageType(notifObject.summary.toLowerCase())}`, 'hugerass', {
diff --git a/.config/ags/scripts/quickscripts/nixos-trim-generations.sh b/.config/ags/scripts/quickscripts/nixos-trim-generations.sh
new file mode 100755
index 000000000..98b59be95
--- /dev/null
+++ b/.config/ags/scripts/quickscripts/nixos-trim-generations.sh
@@ -0,0 +1,243 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+## Defaults
+keepGensDef=30; keepDaysDef=30
+keepGens=$keepGensDef; keepDays=$keepDaysDef
+
+## Usage
+usage () {
+ printf "Usage:\n\t ./trim-generations.sh \n\n
+(defaults are: Keep-Gens=$keepGensDef Keep-Days=$keepDaysDef Profile=user)\n\n"
+ printf "If you enter any parameters, you must enter all three, or none to use defaults.\n"
+ printf "Example:\n\t trim-generations.sh 15 10 home-manager\n"
+ printf " this will work on the home-manager profile and keep all generations from the\n"
+ printf "last 10 days, and keep at least 15 generations no matter how old.\n"
+ printf "\nProfiles available are:\tuser, home-manager, channels, system (root)\n"
+ printf "\n-h or --help prints this help text."
+}
+
+if [ $# -eq 1 ]; then # if help requested
+ if [ $1 = "-h" ]; then
+ usage
+ exit 1;
+ fi
+ if [ $1 = "--help" ]; then
+ usage
+ exit 2;
+ fi
+ printf "Dont recognise your option exiting..\n\n"
+ usage
+ exit 3;
+
+ elif [ $# -eq 0 ]; then # print the defaults
+ printf "The current defaults are:\n Keep-Gens=$keepGensDef Keep-Days=$keepDaysDef \n\n"
+ read -p "Keep these defaults? (y/n):" answer
+
+ case "$answer" in
+ [yY1] )
+ printf "Using defaults..\n"
+ ;;
+ [nN0] ) printf "ok, doing nothing, exiting..\n"
+ exit 6;
+ ;;
+ * ) printf "%b" "Doing nothing, exiting.."
+ exit 7;
+ ;;
+ esac
+fi
+
+## Handle parameters (and change if root)
+if [[ $EUID -ne 0 ]]; then # if not root
+ profile=$(readlink /home/$USER/.nix-profile)
+else
+ if [ -d /nix/var/nix/profiles/system ]; then # maybe this or the other
+ profile="/nix/var/nix/profiles/system"
+ elif [ -d /nix/var/nix/profiles/default ]; then
+ profile="/nix/var/nix/profiles/default"
+ else
+ echo "Cant find profile for root. Exiting"
+ exit 8
+ fi
+fi
+if (( $# < 1 )); then
+ printf "Keeping default: $keepGensDef generations OR $keepDaysDef days, whichever is more\n"
+elif [[ $# -le 2 ]]; then
+ printf "\nError: Not enough arguments.\n\n" >&2
+ usage
+ exit 1
+elif (( $# > 4)); then
+ printf "\nError: Too many arguments.\n\n" >&2
+ usage
+ exit 2
+else
+ if [ $1 -lt 1 ]; then
+ printf "using Gen numbers less than 1 not recommended. Setting to min=1\n"
+ read -p "is that ok? (y/n): " asnwer
+ #printf "$asnwer"
+ case "$asnwer" in
+ [yY1] )
+ printf "ok, continuing..\n"
+ ;;
+ [nN0] )
+ printf "ok, doing nothing, exiting..\n"
+ exit 6;
+ ;;
+ * )
+ printf "%b" "Doing nothing, exiting.."
+ exit 7;
+ ;;
+ esac
+ fi
+ if [ $2 -lt 0 ]; then
+ printf "using negative days number not recommended. Setting to min=0\n"
+ read -p "is that ok? (y/n): " asnwer
+
+ case "$asnwer" in
+ [yY1] )
+ printf "ok, continuing..\n"
+ ;;
+ [nN0] )
+ printf "ok, doing nothing, exiting..\n"
+ exit 6;
+ ;;
+ * )
+ printf "%b" "Doing nothing, exiting.."
+ exit 7;
+ ;;
+ esac
+ fi
+ keepGens=$1; keepDays=$2;
+ (( keepGens < 1 )) && keepGens=1
+ (( keepDays < 0 )) && keepDays=0
+ if [[ $EUID -ne 0 ]]; then
+ if [[ $3 == "user" ]] || [[ $3 == "default" ]]; then
+ profile=$(readlink /home/$USER/.nix-profile)
+ elif [[ $3 == "home-manager" ]]; then
+ # home-manager defaults to $XDG_STATE_HOME; otherwise, use
+ # `home-manager generations` and `nix-store --query --roots
+ # /nix/store/...` to figure out what reference is keeping the old
+ # generations alive.
+ profile="${XDG_STATE_HOME:-$HOME/.local/state}/nix/profiles/home-manager"
+ elif [[ $3 == "channels" ]]; then
+ profile="/nix/var/nix/profiles/per-user/$USER/channels"
+ else
+ printf "\nError: Do not understand your third argument. Should be one of: (user / home-manager/ channels)\n\n"
+ usage
+ exit 3
+ fi
+ else
+ if [[ $3 == "system" ]]; then
+ profile="/nix/var/nix/profiles/system"
+ elif [[ $3 == "user" ]] || [[ $3 == "default" ]]; then
+ profile="/nix/var/nix/profiles/default"
+ else
+ printf "\nError: Do not understand your third argument. Should be one of: (user / system)\n\n"
+ usage
+ exit 3
+ fi
+ fi
+ printf "OK! \t Keep Gens = $keepGens \t Keep Days = $keepDays\n\n"
+fi
+
+printf "Operating on profile: \t $profile\n\n"
+
+## Runs at the end, to decide whether to delete profiles that match chosen parameters.
+choose () {
+ local default="$1"
+ local prompt="$2"
+ local answer
+
+ read -p "$prompt" answer
+ [ -z "$answer" ] && answer="$default"
+
+ case "$answer" in
+ [yY1] ) #printf "answered yes!\n"
+ nix-env --delete-generations -p $profile ${!gens[@]}
+ exit 0
+ ;;
+ [nN0] ) printf "Ok doing nothing exiting..\n"
+ exit 6;
+ ;;
+ * ) printf "%b" "Unexpected answer '$answer'!" >&2
+ exit 7;
+ ;;
+ esac
+} # end of function choose
+
+# printf "profile = $profile\n\n"
+## Query nix-env for generations list
+IFS=$'\n' nixGens=( $(nix-env --list-generations -p $profile | sed 's:^\s*::; s:\s*$::' | tr '\t' ' ' | tr -s ' ') )
+timeNow=$(date +%s)
+
+## Get info on oldest generation
+IFS=' ' read -r -a oldestGenArr <<< "${nixGens[0]}"
+oldestGen=${oldestGenArr[0]}
+oldestDate=${oldestGenArr[1]}
+printf "%-30s %s\n" "oldest generation:" $oldestGen
+#oldestDate=${nixGens[0]:3:19}
+printf "%-30s %s\n" "oldest generation created:" $oldestDate
+oldestTime=$(date -d "$oldestDate" +%s)
+oldestElapsedSecs=$((timeNow-oldestTime))
+oldestElapsedMins=$((oldestElapsedSecs/60))
+oldestElapsedHours=$((oldestElapsedMins/60))
+oldestElapsedDays=$((oldestElapsedHours/24))
+printf "%-30s %s\n" "minutes before now:" $oldestElapsedMins
+printf "%-30s %s\n" "hours before now:" $oldestElapsedHours
+printf "%-30s %s\n\n" "days before now:" $oldestElapsedDays
+
+## Get info on current generation
+for i in "${nixGens[@]}"; do
+ IFS=' ' read -r -a iGenArr <<< "$i"
+ genNumber=${iGenArr[0]}
+ genDate=${iGenArr[1]}
+ if [[ "$i" =~ current ]]; then
+ currentGen=$genNumber
+ printf "%-30s %s\n" "current generation:" $currentGen
+ currentDate=$genDate
+ printf "%-30s %s\n" "current generation created:" $currentDate
+ currentTime=$(date -d "$currentDate" +%s)
+ currentElapsedSecs=$((timeNow-currentTime))
+ currentElapsedMins=$((currentElapsedSecs/60))
+ currentElapsedHours=$((currentElapsedMins/60))
+ currentElapsedDays=$((currentElapsedHours/24))
+ printf "%-30s %s\n" "minutes before now:" $currentElapsedMins
+ printf "%-30s %s\n" "hours before now:" $currentElapsedHours
+ printf "%-30s %s\n\n" "days before now:" $currentElapsedDays
+ fi
+done
+
+## Compare oldest and current generations
+timeBetweenOldestAndCurrent=$((currentTime-oldestTime))
+elapsedDays=$((timeBetweenOldestAndCurrent/60/60/24))
+generationsDiff=$((currentGen-oldestGen))
+
+## Figure out what we should do, based on generations and options
+if [[ elapsedDays -le keepDays ]]; then
+ printf "All generations are no more than $keepDays days older than current generation. \nOldest gen days difference from current gen: $elapsedDays \n\n\tNothing to do!\n"
+ exit 4;
+elif [[ generationsDiff -lt keepGens ]]; then
+ printf "Oldest generation ($oldestGen) is only $generationsDiff generations behind current ($currentGen). \n\n\t Nothing to do!\n"
+ exit 5;
+else
+ printf "\tSomething to do...\n"
+ declare -a gens
+ for i in "${nixGens[@]}"; do
+ IFS=' ' read -r -a iGenArr <<< "$i"
+ genNumber=${iGenArr[0]}
+ genDiff=$((currentGen-genNumber))
+ genDate=${iGenArr[1]}
+ genTime=$(date -d "$genDate" +%s)
+ elapsedSecs=$((timeNow-genTime))
+ genDaysOld=$((elapsedSecs/60/60/24))
+ if [[ genDaysOld -gt keepDays ]] && [[ genDiff -ge keepGens ]]; then
+ gens["$genNumber"]="$genDate, $genDaysOld day(s) old"
+ fi
+ done
+ printf "\nFound the following generation(s) to delete:\n"
+ for K in "${!gens[@]}"; do
+ printf "generation $K \t ${gens[$K]}\n"
+ done
+ printf "\n"
+ choose "y" "Do you want to delete these? [Y/n]: "
+fi
diff --git a/.config/ags/scripts/templates/gradience/preset.json b/.config/ags/scripts/templates/gradience/preset.json
index 243111683..2605d5954 100644
--- a/.config/ags/scripts/templates/gradience/preset.json
+++ b/.config/ags/scripts/templates/gradience/preset.json
@@ -87,9 +87,9 @@
"BLACK_500": "#393634",
"BLACK_700": "#33302F",
"BLACK_900": "#2B2928",
- "accent_bg_color": "#ffb1c3",
- "accent_fg_color": "#66002a",
- "accent_color": "#ffb1c3",
+ "accent_bg_color": "#efc048",
+ "accent_fg_color": "#3f2e00",
+ "accent_color": "#efc048",
"destructive_bg_color": "#ffb4a9",
"destructive_fg_color": "#680003",
"destructive_color": "#ffb4a9",
@@ -99,22 +99,22 @@
"warning_fg_color": "rgba(0, 0, 0, 0.87)",
"error_bg_color": "#ffb4a9",
"error_fg_color": "#680003",
- "window_bg_color": "#130F10",
- "window_fg_color": "#ecdfe0",
- "view_bg_color": "#201a1b",
- "view_fg_color": "#ecdfe0",
+ "window_bg_color": "#12100D",
+ "window_fg_color": "#e8e1d8",
+ "view_bg_color": "#1e1b16",
+ "view_fg_color": "#e8e1d8",
"headerbar_bg_color": "mix(@dialog_bg_color, @window_bg_color, 0.5)",
- "headerbar_fg_color": "#ffd9df",
- "headerbar_border_color": "#5c3f45",
+ "headerbar_fg_color": "#f3e0ba",
+ "headerbar_border_color": "#514529",
"headerbar_backdrop_color": "@headerbar_bg_color",
"headerbar_shade_color": "rgba(0, 0, 0, 0.09)",
- "card_bg_color": "#130F10",
- "card_fg_color": "#ffd9df",
+ "card_bg_color": "#12100D",
+ "card_fg_color": "#f3e0ba",
"card_shade_color": "rgba(0, 0, 0, 0.09)",
- "dialog_bg_color": "#5c3f45",
- "dialog_fg_color": "#ffd9df",
- "popover_bg_color": "#5c3f45",
- "popover_fg_color": "#ffd9df",
+ "dialog_bg_color": "#514529",
+ "dialog_fg_color": "#f3e0ba",
+ "popover_bg_color": "#514529",
+ "popover_fg_color": "#f3e0ba",
"thumbnail_bg_color": "#1a1b26",
"thumbnail_fg_color": "#AEE5FA",
"shade_color": "rgba(0, 0, 0, 0.36)",
diff --git a/.config/ags/scss/_bar.scss b/.config/ags/scss/_bar.scss
index 7ad45ed44..f83566092 100644
--- a/.config/ags/scss/_bar.scss
+++ b/.config/ags/scss/_bar.scss
@@ -285,6 +285,7 @@ $bar_subgroup_bg: $surfaceVariant;
@include element_decel;
min-height: 1.032rem;
min-width: 1.032rem;
+ font-size: 1.032rem;
}
.bar-statusicons {
diff --git a/.config/ags/scss/_dock.scss b/.config/ags/scss/_dock.scss
index d9c0001a9..2965726ab 100644
--- a/.config/ags/scss/_dock.scss
+++ b/.config/ags/scss/_dock.scss
@@ -22,6 +22,7 @@
.dock-app-icon {
min-width: 3.409rem;
min-height: 3.409rem;
+ font-size: 3.409rem;
}
.dock-separator {
diff --git a/.config/ags/scss/_material.scss b/.config/ags/scss/_material.scss
index 2bce3c53d..be24bb0b5 100644
--- a/.config/ags/scss/_material.scss
+++ b/.config/ags/scss/_material.scss
@@ -1,29 +1,29 @@
$darkmode: true;
-$primary: #ffb1c3;
-$onPrimary: #66002a;
-$primaryContainer: #861c40;
-$onPrimaryContainer: #ffd9e0;
-$secondary: #e4bcc3;
-$onSecondary: #42292e;
-$secondaryContainer: #5c3f45;
-$onSecondaryContainer: #ffd9df;
-$tertiary: #ecbe91;
-$onTertiary: #462a08;
-$tertiaryContainer: #60401d;
-$onTertiaryContainer: #ffdcb9;
+$primary: #efc048;
+$onPrimary: #3f2e00;
+$primaryContainer: #5b4300;
+$onPrimaryContainer: #ffdf93;
+$secondary: #d7c5a1;
+$onSecondary: #3a2f15;
+$secondaryContainer: #514529;
+$onSecondaryContainer: #f3e0ba;
+$tertiary: #afcfab;
+$onTertiary: #1c361d;
+$tertiaryContainer: #324d32;
+$onTertiaryContainer: #cbebc6;
$error: #ffb4a9;
$onError: #680003;
$errorContainer: #930006;
$onErrorContainer: #ffb4a9;
-$colorbarbg: #130F10;
-$background: #130F10;
-$onBackground: #ecdfe0;
-$surface: #201a1b;
-$onSurface: #ecdfe0;
-$surfaceVariant: #514345;
-$onSurfaceVariant: #d6c1c4;
-$outline: #9f8c8f;
+$colorbarbg: #12100D;
+$background: #12100D;
+$onBackground: #e8e1d8;
+$surface: #1e1b16;
+$onSurface: #e8e1d8;
+$surfaceVariant: #4d4639;
+$onSurfaceVariant: #d0c5b4;
+$outline: #999080;
$shadow: #000000;
-$inverseSurface: #ecdfe0;
-$inverseOnSurface: #362f30;
-$inversePrimary: #a53557;
+$inverseSurface: #e8e1d8;
+$inverseOnSurface: #33302a;
+$inversePrimary: #785a00;
diff --git a/.config/ags/scss/_notifications.scss b/.config/ags/scss/_notifications.scss
index a5de8e7c5..2eab85052 100644
--- a/.config/ags/scss/_notifications.scss
+++ b/.config/ags/scss/_notifications.scss
@@ -95,6 +95,7 @@ $notif_surface: $t_background;
@include full-rounding;
min-width: 3.409rem;
min-height: 3.409rem;
+ font-size: 3.409rem;
}
.notif-icon-material {
diff --git a/.config/ags/scss/_sidebars.scss b/.config/ags/scss/_sidebars.scss
index c6b00853b..7e8dad8af 100644
--- a/.config/ags/scss/_sidebars.scss
+++ b/.config/ags/scss/_sidebars.scss
@@ -445,15 +445,30 @@ $onChatgpt: $onPrimary;
.sidebar-module {
@include normal-rounding;
@include group-padding;
- background-color: $t_surface;
+ background-color: $l_l_t_surfaceVariant;
+ padding: 0.682rem;
}
.sidebar-module-btn-arrow {
@include full-rounding;
@include icon-material;
- background-color: $t_surfaceVariant;
+ background-color: $l_l_t_surfaceVariant;
min-width: 1.705rem;
min-height: 1.705rem;
+ &:hover {
+ background-color: $hovercolor;
+ }
+}
+
+.sidebar-module-scripts-button {
+ @include full-rounding;
+ @include icon-material;
+ background-color: $l_l_t_surfaceVariant;
+ min-width: 1.705rem;
+ min-height: 1.705rem;
+ &:hover {
+ background-color: $hovercolor;
+ }
}
.sidebar-chat-apiswitcher {
@@ -467,6 +482,7 @@ $onChatgpt: $onPrimary;
@include full-rounding;
min-width: 2.182rem;
min-height: 2.182rem;
+ font-size: 1.406rem;
color: $onSurface;
}
@@ -642,10 +658,10 @@ $onChatgpt: $onPrimary;
.sidebar-chat-welcome-logo {
@include full-rounding;
@include element_decel;
+ @include icon-material;
min-height: 4.773rem;
min-width: 4.773rem;
- @include icon-material;
- font-size: 2.727rem;
+ font-size: 3.076rem;
background-color: $onBackground;
color: $background;
}
diff --git a/.config/ags/services/chatgpt.js b/.config/ags/services/chatgpt.js
index 793d1a50f..fcae27f3f 100644
--- a/.config/ags/services/chatgpt.js
+++ b/.config/ags/services/chatgpt.js
@@ -118,8 +118,8 @@ class ChatGPTService extends Service {
_assistantPrompt = true;
_messages = [];
_cycleModels = true;
- _temperature = 0.9;
_requestCount = 0;
+ _temperature = 0.9;
_modelIndex = 0;
_key = '';
_decoder = new TextDecoder();
diff --git a/.config/ags/services/gemini.js b/.config/ags/services/gemini.js
index 02b501765..edbc4ad7d 100644
--- a/.config/ags/services/gemini.js
+++ b/.config/ags/services/gemini.js
@@ -135,8 +135,8 @@ class GeminiService extends Service {
_assistantPrompt = true;
_messages = [];
_cycleModels = true;
- _temperature = 0.9;
_requestCount = 0;
+ _temperature = 0.9;
_modelIndex = 0;
_key = '';
_decoder = new TextDecoder();
diff --git a/.config/ags/widgets/bar/tray.js b/.config/ags/widgets/bar/tray.js
index 67d65a833..69c48e23a 100644
--- a/.config/ags/widgets/bar/tray.js
+++ b/.config/ags/widgets/bar/tray.js
@@ -10,15 +10,8 @@ const SysTrayItem = (item) => Button({
className: 'bar-systray-item',
child: Icon({
hpack: 'center',
- setup: (self) => {
- self.hook(item, (self) => self.icon = item.icon);
- Utils.timeout(1, () => {
- const styleContext = self.get_parent().get_style_context();
- const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
- const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
- self.size = Math.max(width, height, 1); // im too lazy to add another box lol
- })
- },
+ icon: item.icon,
+ setup: (self) => self.hook(item, (self) => self.icon = item.icon),
}),
setup: (self) => self
.hook(item, (self) => self.tooltipMarkup = item['tooltip-markup'])
diff --git a/.config/ags/widgets/dock/dock.js b/.config/ags/widgets/dock/dock.js
index f0192d8cc..9a63d3586 100644
--- a/.config/ags/widgets/dock/dock.js
+++ b/.config/ags/widgets/dock/dock.js
@@ -59,12 +59,6 @@ const AppButton = ({ icon, ...rest }) => Widget.Revealer({
className: 'dock-app-icon',
child: Widget.Icon({
icon: icon,
- setup: (self) => Utils.timeout(1, () => {
- const styleContext = self.get_parent().get_style_context();
- const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
- const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
- self.size = Math.max(width, height, 1);
- })
}),
}),
overlays: [Widget.Box({
diff --git a/.config/ags/widgets/overview/searchbuttons.js b/.config/ags/widgets/overview/searchbuttons.js
index 8ea12c887..15130ad05 100644
--- a/.config/ags/widgets/overview/searchbuttons.js
+++ b/.config/ags/widgets/overview/searchbuttons.js
@@ -38,12 +38,6 @@ export const DirectoryButton = ({ parentPath, name, type, icon }) => {
homogeneous: true,
child: Widget.Icon({
icon: icon,
- setup: (self) => Utils.timeout(1, () => {
- const styleContext = self.get_parent().get_style_context();
- const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
- const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
- self.size = Math.max(width, height, 1);
- })
}),
}),
Widget.Label({
@@ -112,12 +106,6 @@ export const DesktopEntryButton = (app) => {
homogeneous: true,
child: Widget.Icon({
icon: app.iconName,
- setup: (self) => Utils.timeout(1, () => {
- const styleContext = self.get_parent().get_style_context();
- const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
- const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
- self.size = Math.max(width, height, 1);
- })
}),
}),
Widget.Label({
diff --git a/.config/ags/widgets/overview/windowcontent.js b/.config/ags/widgets/overview/windowcontent.js
index e4b46c178..5a9dd8882 100644
--- a/.config/ags/widgets/overview/windowcontent.js
+++ b/.config/ags/widgets/overview/windowcontent.js
@@ -243,11 +243,11 @@ export const SearchAndWindows = () => {
entry.set_position(Math.max(entry.get_position() - 1, 0));
else if (keyval == Gdk.KEY_f)
entry.set_position(Math.min(entry.get_position() + 1, entry.get_text().length));
- if (keyval == Gdk.KEY_n) { // simulate Down arrow
+ else if (keyval == Gdk.KEY_n) { // simulate Down arrow
entry.get_root_window().simulate_key_press(Gdk.KEY_Down, Gdk.ModifierType.NONE);
// entry.get_root_window().simulate_key_release(Gdk.KEY_Down, Gdk.ModifierType.NONE);
}
- if (keyval == Gdk.KEY_k) { // Delete to end
+ else if (keyval == Gdk.KEY_k) { // Delete to end
const text = entry.get_text();
const pos = entry.get_position();
const newText = text.slice(0, pos);
diff --git a/.config/ags/widgets/sideleft/apis/ai_chatmessage.js b/.config/ags/widgets/sideleft/apis/ai_chatmessage.js
index 66b589cd1..d2cf8d20a 100644
--- a/.config/ags/widgets/sideleft/apis/ai_chatmessage.js
+++ b/.config/ags/widgets/sideleft/apis/ai_chatmessage.js
@@ -44,6 +44,7 @@ function copyToClipboard(text) {
function substituteLang(str) {
const subs = [
{ from: 'javascript', to: 'js' },
+ { from: 'bash', to: 'sh' },
];
for (const { from, to } of subs) {
@@ -58,7 +59,7 @@ const HighlightedCode = (content, lang) => {
const buffer = new GtkSource.Buffer();
const sourceView = new GtkSource.View({
buffer: buffer,
- wrap_mode: Gtk.WrapMode.WORD
+ wrap_mode: Gtk.WrapMode.NONE
});
const langManager = GtkSource.LanguageManager.get_default();
let displayLang = langManager.get_language(substituteLang(lang)); // Set your preferred language
diff --git a/.config/ags/widgets/sideleft/apis/chatgpt.js b/.config/ags/widgets/sideleft/apis/chatgpt.js
index 91de66250..16e54b161 100644
--- a/.config/ags/widgets/sideleft/apis/chatgpt.js
+++ b/.config/ags/widgets/sideleft/apis/chatgpt.js
@@ -19,14 +19,6 @@ export const chatGPTTabIcon = Icon({
hpack: 'center',
className: 'sidebar-chat-apiswitcher-icon',
icon: `openai-symbolic`,
- setup: (self) => Utils.timeout(513, () => { // stupid condition race
- const styleContext = self.get_style_context();
- const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
- const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
- // console.log(Math.round(Math.max(width, height, 1)));
- self.size = Math.max(width, height, 1) * 116 / 180;
- // ↑ Why such a specific proportion? See https://openai.com/brand#logos
- })
});
const ChatGPTInfo = () => {
@@ -34,14 +26,6 @@ const ChatGPTInfo = () => {
hpack: 'center',
className: 'sidebar-chat-welcome-logo',
icon: `openai-symbolic`,
- setup: (self) => Utils.timeout(513, () => { // stupid condition race
- const styleContext = self.get_style_context();
- const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
- const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
- // console.log(Math.round(Math.max(width, height, 1)));
- self.size = Math.max(width, height, 1) * 116 / 180;
- // ↑ Why such a specific proportion? See https://openai.com/brand#logos
- })
});
return Box({
vertical: true,
diff --git a/.config/ags/widgets/sideleft/apis/gemini.js b/.config/ags/widgets/sideleft/apis/gemini.js
index 0931c9730..6d9da681d 100644
--- a/.config/ags/widgets/sideleft/apis/gemini.js
+++ b/.config/ags/widgets/sideleft/apis/gemini.js
@@ -20,12 +20,6 @@ export const geminiTabIcon = Icon({
hpack: 'center',
className: 'sidebar-chat-apiswitcher-icon',
icon: `google-gemini-symbolic`,
- setup: (self) => Utils.timeout(513, () => { // stupid condition race
- const styleContext = self.get_style_context();
- const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
- const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
- self.size = Math.max(width, height, 1) * 116 / 180;
- })
})
const GeminiInfo = () => {
@@ -33,12 +27,6 @@ const GeminiInfo = () => {
hpack: 'center',
className: 'sidebar-chat-welcome-logo',
icon: `google-gemini-symbolic`,
- setup: (self) => Utils.timeout(513, () => { // stupid condition race
- const styleContext = self.get_style_context();
- const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
- const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
- self.size = Math.max(width, height, 1) * 116 / 180;
- })
});
return Box({
vertical: true,
diff --git a/.config/ags/widgets/sideleft/module.js b/.config/ags/widgets/sideleft/module.js
index 319b5a35c..166370f09 100644
--- a/.config/ags/widgets/sideleft/module.js
+++ b/.config/ags/widgets/sideleft/module.js
@@ -1,30 +1,53 @@
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
-const { Box, Button, Label } = Widget;
+import { setupCursorHover } from '../../lib/cursorhover.js';
+import { MaterialIcon } from '../../lib/materialicon.js';
+const { Box, Button, Icon, Label, Revealer } = Widget;
export const SidebarModule = ({
+ icon,
name,
child
}) => {
+ const headerButtonIcon = MaterialIcon('expand_more', 'norm');
+ const header = Box({
+ className: 'spacing-h-10',
+ children: [
+ icon,
+ Label({
+ className: 'txt-norm txt',
+ label: `${name}`,
+ }),
+ Box({
+ hexpand: true,
+ }),
+ Button({
+ className: 'sidebar-module-btn-arrow txt',
+ child: headerButtonIcon,
+ onClicked: () => {
+ console.log('clicked');
+ content.revealChild = !content.revealChild;
+ headerButtonIcon.label = content.revealChild ? 'expand_less' : 'expand_more';
+ },
+ setup: setupCursorHover,
+ })
+ ]
+ });
+ const content = Revealer({
+ revealChild: true,
+ transition: 'slide_down',
+ transitionDuration: 200,
+ child: Box({
+ className: 'margin-top-5',
+ homogeneous: true,
+ children: [child],
+ }),
+ });
return Box({
className: 'sidebar-module',
vertical: true,
children: [
- Button({
- child: Box({
- children: [
- Label({
- className: 'txt-small txt',
- label: `${name}`,
- }),
- Box({
- hexpand: true,
- }),
- Label({
- className: 'sidebar-module-btn-arrow',
- })
- ]
- })
- })
+ header,
+ content,
]
});
}
\ No newline at end of file
diff --git a/.config/ags/widgets/sideleft/quickscripts.js b/.config/ags/widgets/sideleft/quickscripts.js
index 13bf9c1a1..483e2365c 100644
--- a/.config/ags/widgets/sideleft/quickscripts.js
+++ b/.config/ags/widgets/sideleft/quickscripts.js
@@ -1,11 +1,95 @@
+const { Gtk } = imports.gi;
+import App from 'resource:///com/github/Aylur/ags/app.js';
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
const { execAsync, exec } = Utils;
-const { Box, Button, EventBox, Label, Scrollable } = Widget;
+const { Box, Button, EventBox, Icon, Label, Scrollable } = Widget;
import { SidebarModule } from './module.js';
+import { MaterialIcon } from '../../lib/materialicon.js';
+import { setupCursorHover } from '../../lib/cursorhover.js';
+
+Gtk.IconTheme.get_default().append_search_path(`${App.configDir}/assets`);
+const distroID = exec(`bash -c 'cat /etc/os-release | grep "^ID=" | cut -d "=" -f 2'`).trim();
+const isDebianDistro = (distroID == 'linuxmint' || distroID == 'ubuntu' || distroID == 'debian' || distroID == 'zorin' || distroID == 'pop' || distroID == 'raspbian' || distroID == 'kali' || distroID == 'elementary');
+const isArchDistro = (distroID == 'arch' || distroID == 'endeavouros');
+const hasFlatpak = !!exec(`bash -c 'command -v flatpak'`);
+
+const scripts = [
+ {
+ icon: 'nixos-symbolic',
+ name: 'Trim system generations to 5',
+ command: `sudo ${App.configDir}/scripts/quickscripts/nixos-trim-generations.sh 5 0 system`,
+ enabled: distroID == 'nixos',
+ },
+ {
+ icon: 'nixos-symbolic',
+ name: 'Trim home manager generations to 5',
+ command: `${App.configDir}/scripts/quickscripts/nixos-trim-generations.sh 5 0 home-manager`,
+ enabled: distroID == 'nixos',
+ },
+ {
+ icon: 'ubuntu-symbolic',
+ name: 'Update packages',
+ command: `sudo apt update && sudo apt upgrade -y`,
+ enabled: isDebianDistro,
+ },
+ {
+ icon: 'fedora-symbolic',
+ name: 'Update packages',
+ command: `sudo dnf upgrade -y`,
+ enabled: distroID == 'fedora',
+ },
+ {
+ icon: 'arch-symbolic',
+ name: 'Update packages',
+ command: `sudo pacman -Syyu`,
+ enabled: isArchDistro,
+ },
+ {
+ icon: 'flatpak-symbolic',
+ name: 'Uninstall unused flatpak packages',
+ command: `flatpak uninstall --unused`,
+ enabled: hasFlatpak,
+ },
+];
export const QuickScripts = () => SidebarModule({
+ icon: MaterialIcon('code', 'norm'),
name: 'Quick scripts',
child: Box({
+ vertical: true,
+ className: 'spacing-v-5',
+ children: scripts.map((script) => {
+ if (!script.enabled) return null;
+ const scriptStateIcon = MaterialIcon('not_started', 'norm');
+ return Box({
+ className: 'spacing-h-5 txt',
+ children: [
+ Icon({
+ className: 'sidebar-module-btn-icon txt-large',
+ icon: script.icon,
+ }),
+ Label({
+ className: 'txt-small',
+ hpack: 'start',
+ hexpand: true,
+ label: script.name,
+ tooltipText: script.command,
+ }),
+ Button({
+ className: 'sidebar-module-scripts-button',
+ child: scriptStateIcon,
+ onClicked: () => {
+ App.closeWindow('sideleft');
+ execAsync([`bash`, `-c`, `foot fish -C "${script.command}"`]).catch(print)
+ .then(() => {
+ scriptStateIcon.label = 'done';
+ })
+ },
+ setup: setupCursorHover,
+ }),
+ ],
+ })
+ }),
})
-})
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/.config/ags/widgets/sideleft/toolbox.js b/.config/ags/widgets/sideleft/toolbox.js
index 0c14beded..1fbf71792 100644
--- a/.config/ags/widgets/sideleft/toolbox.js
+++ b/.config/ags/widgets/sideleft/toolbox.js
@@ -10,7 +10,7 @@ export default Scrollable({
child: Box({
vertical: true,
children: [
- // QuickScripts(),
+ QuickScripts(),
]
})
});