forked from ublue-os/bluefin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ublue-os:main' into main
- Loading branch information
Showing
11 changed files
with
219 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/bash | ||
|
||
# Choose to enable or disable bluefin-cli | ||
|
||
# shellcheck disable=1091 | ||
# shellcheck disable=2206 | ||
# shellcheck disable=2154 | ||
source /usr/lib/ujust/ujust.sh | ||
|
||
bluefin_cli=(${red}Disabled${n} ${red}Inactive${n}) | ||
|
||
function get_status(){ | ||
if systemctl --quiet --user is-enabled bluefin-cli.target; then | ||
bluefin_cli[0]="${green}Enabled${n}" | ||
else | ||
bluefin_cli[0]="${red}Disabled${n}" | ||
fi | ||
if systemctl --quiet --user is-active bluefin-cli.service; then | ||
bluefin_cli[1]="${green}Active${n}" | ||
else | ||
bluefin_cli[1]="${red}Inactive${n}" | ||
fi | ||
echo "Bluefin-cli is currently ${b}${bluefin_cli[0]}${n} and ${b}${bluefin_cli[1]}${n}" | ||
} | ||
function logic(){ | ||
if test "$toggle" = "Enable"; then | ||
echo "${b}${green}Enabling${n} Bluefin-CLI" | ||
systemctl --user enable --now bluefin-cli.target > /dev/null 2>&1 | ||
if ! systemctl --quiet --user is-active bluefin-cli.service; then | ||
systemctl --user reset-failed bluefin-cli.service > /dev/null 2>&1 || true | ||
echo "${b}${green}Starting${n} Bluefin-CLI" | ||
systemctl --user start bluefin-cli.service | ||
fi | ||
elif test "$toggle" = "Disable"; then | ||
echo "${b}${red}Disabling${n} Bluefin-CLI" | ||
systemctl --user disable --now bluefin-cli.target > /dev/null 2>&1 | ||
if systemctl --quiet --user is-active bluefin-cli.service; then | ||
echo "Do you want to ${b}${red}Stop${n} the Container?" | ||
stop=$(Confirm) | ||
if test "$stop" -eq 0; then | ||
systemctl --user stop bluefin-cli.service > /dev/null 2>&1 | ||
systemctl --user reset-failed bluefin-cli.service > /dev/null 2>&1 || true | ||
fi | ||
fi | ||
else | ||
echo "Not Changing" | ||
fi | ||
} | ||
|
||
function main(){ | ||
get_status | ||
toggle=$(Choose Enable Disable Cancel) | ||
logic | ||
get_status | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/bash | ||
|
||
# Read the current value of the array | ||
CURRENT_VALUE=$(dconf read /org/gnome/Prompt/profile-uuids) | ||
guid=$1 | ||
|
||
# remove the leading and trailing brackets | ||
CURRENT_VALUE=${CURRENT_VALUE:1:-1} | ||
|
||
# remove any spaces | ||
CURRENT_VALUE=${CURRENT_VALUE// /} | ||
|
||
# split the string into an array | ||
IFS=',' read -r -a array <<<"$CURRENT_VALUE" | ||
|
||
# add the new value | ||
array+=("'$guid'") | ||
|
||
# join the array back into a string | ||
UPDATED_VALUE=$(printf "%s," "${array[@]}") | ||
|
||
# remove the trailing comma | ||
UPDATED_VALUE=${UPDATED_VALUE%?} | ||
|
||
# add the leading and trailing brackets | ||
UPDATED_VALUE="[$UPDATED_VALUE]" | ||
|
||
# Write the updated array back to dconf | ||
dconf write /org/gnome/Prompt/profile-uuids "$UPDATED_VALUE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/bash | ||
|
||
# create a Prompt profile using dconf given the guid of the instance | ||
# $1 = name | ||
|
||
# dconf read /org/gnome/Prompt/Profiles/d092b3519698570a3252762c658f7629/ | ||
# /org/gnome/Prompt/Profiles/d092b3519698570a3252762c658f7629/custom-command | ||
# 'blincus shell myubuntu' | ||
# /org/gnome/Prompt/Profiles/d092b3519698570a3252762c658f7629/label | ||
# 'myubuntu' | ||
# /org/gnome/Prompt/Profiles/d092b3519698570a3252762c658f7629/login-shell | ||
# true | ||
# /org/gnome/Prompt/Profiles/d092b3519698570a3252762c658f7629/use-custom-command | ||
# true | ||
|
||
# if dconf doesn't exist, just return | ||
if ! command -v dconf >/dev/null; then | ||
return | ||
fi | ||
|
||
# shellcheck disable=SC2001 | ||
gen_uuid() { | ||
uuid="$(cat /proc/sys/kernel/random/uuid)" | ||
echo "$uuid" | sed 's/-//g' | ||
} | ||
|
||
guid=$(gen_uuid) | ||
name="$1" | ||
palette="$2" | ||
|
||
profile="/org/gnome/Prompt/Profiles/${guid}/" | ||
|
||
dconf write "${profile}custom-command" "'sh -c \"[ ! -e /run/.containerenv ] && [ ! -e /run/.dockerenv ] && distrobox enter ${name} || ${SHELL}\"'" | ||
dconf write "${profile}label" "'${name}'" | ||
dconf write "${profile}use-custom-command" "true" | ||
if test -n "$palette"; then | ||
dconf write "${profile}palette" "'${palette}'" | ||
elif test "$name" = "bluefin-cli"; then | ||
dconf write "${profile}palette" "'catppuccin-dynamic'" | ||
fi | ||
|
||
/usr/libexec/prompt-add-profile.sh "$guid" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/bash | ||
# ensure that the prompt profiles for deleted instances are removed | ||
|
||
# if dconf doesn't exist, just return | ||
if ! command -v dconf >/dev/null; then | ||
return | ||
fi | ||
|
||
name="$1" | ||
|
||
# Read the current value of the array | ||
CURRENT_VALUE=$(dconf read /org/gnome/Prompt/profile-uuids) | ||
|
||
# remove the leading and trailing brackets | ||
CURRENT_VALUE=${CURRENT_VALUE:1:-1} | ||
|
||
# remove any spaces | ||
CURRENT_VALUE=${CURRENT_VALUE// /} | ||
|
||
# split the string into an array | ||
IFS=',' read -r -a array <<<"$CURRENT_VALUE" | ||
|
||
# loop through the array and remove any that don't exist | ||
for i in "${!array[@]}"; do | ||
guid=${array[i]} | ||
|
||
# remove single quotes from guid | ||
|
||
guid=${guid//\'/} | ||
|
||
#echo "Checking profile for $(red $guid)" | ||
profile="/org/gnome/Prompt/Profiles/${guid}/" | ||
|
||
custom_shell=$(dconf read "${profile}custom-command") | ||
|
||
if [[ $custom_shell == *"[ ! -e /run/.containerenv ] && [ ! -e /run/.dockerenv ] && distrobox enter ${name}"* ]]; then | ||
dconf reset -f "${profile}" | ||
# remove the guid from the array | ||
unset 'array[i]' | ||
# join the array back into a string | ||
UPDATED_VALUE=$(printf "%s," "${array[@]}") | ||
|
||
# remove the trailing comma | ||
UPDATED_VALUE=${UPDATED_VALUE%?} | ||
|
||
# add the leading and trailing brackets | ||
UPDATED_VALUE="[$UPDATED_VALUE]" | ||
|
||
# Write the updated array back to dconf | ||
dconf write /org/gnome/Prompt/profile-uuids "$UPDATED_VALUE" | ||
fi | ||
done |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
|
||
[Service] | ||
ExecStartPre=-/usr/libexec/prompt-remove-profile.sh %N | ||
ExecStartPost=-/usr/libexec/prompt-create-profile.sh %N | ||
ExecStop=-/usr/libexec/prompt-remove-profile.sh %N |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters