Closed Botspot closed 9 months ago
Yeah, I pointed it out in the readme three years ago: https://github.com/actionschnitzel/PiGro-Aid-#exclamation-important
x-terminal-emulator
is used by PiGro when an execution is intended to be in an external window.
The reason for using xterm
is that it integrates very well into Python/Tkinter. Unfortunately, I haven't found a better solution yet.
This is my current method for embedding:
os.popen(
f'xterm -into %d -bg Grey11 -geometry {frame_height}x{frame_width} -e "pkexec apt update -y |lolcat && sleep 5 && exit ; exec bash"'
% wid
)
I've been thinking about a solution for a while. The problem is that sometimes a program in PiOS is set as the new default during installation, which can be really annoying. For example, when you install VSCode, it is set as xdg-open to open directories. So, if I download something in a browser and open the download folder, VSCode will be opened.
Basicly it is a Raspberry Pi OS Problem :-D . On my Pi5 i use Ubuntu 23.10 and when i install PiGro my default (tilix) stays default.
Update: To undo the changes I will implement this
sudo update-alternatives --set x-terminal-emulator /bin/lxterminal
Add to: ## 2st Test Feedback https://github.com/actionschnitzel/PiGro-Aid-/issues/74
Update: To undo the changes I will implement this
sudo update-alternatives --set x-terminal-emulator /bin/lxterminal
Add to: ## 2st Test Feedback #74
No that's bad on systems without lxterminal installed or on systems where the user has already picked a custom terminal of choice.
At a minimum, it should detect and store the original x-terminal-emulator
preference, see if it changes to xterm, and change it back to the original value only if it changed to xterm
during installation.
Update: To undo the changes I will implement this
sudo update-alternatives --set x-terminal-emulator /bin/lxterminal
Add to: ## 2st Test Feedback #74No that's bad on systems without lxterminal installed or on systems where the user has already picked a custom terminal of choice. At a minimum, it should detect and store the original
x-terminal-emulator
preference, see if it changes to xterm, and change it back to the original value only if it changed toxterm
during installation.
No, no. I'm not going to include the command as it is. The plan is to write a script to capture exactly what the default was before and whether xterm is now the default
Possible solution:
#!/bin/bash
# Check the current default x-terminal-emulator
current_default=$(readlink /etc/alternatives/x-terminal-emulator)
if [ "$current_default" = "/usr/bin/xterm" ]; then
terminals=("lxterminal" "xfce4-terminal" "mate-terminal" "uxterm" "xterm" "urxvt" "konsole" "terminator" "gnome-terminal" "gnome-terminal.wrapper" "qterminal" "tilix.wrapper")
latest_timestamp=""
latest_terminal=""
for terminal in "${terminals[@]}"
do
path="/usr/bin/$terminal"
if [ -e "$path" ]; then
timestamp=$(ls -l --time=atime "$path" | awk '{print $6, $7}')
echo "$terminal: $timestamp"
# Check if this timestamp is newer than the currently known latest
if [[ "$timestamp" > "$latest_timestamp" ]]; then
latest_timestamp=$timestamp
latest_terminal=$terminal
fi
else
echo "$terminal not found."
fi
done
echo -e "\nLatest x-terminal-emulator:"
ls -l --time=atime /etc/alternatives/x-terminal-emulator
echo -e "\nLatest standard terminal emulator is $latest_terminal."
# Set x-terminal-emulator to the last used terminal emulator
sudo update-alternatives --set x-terminal-emulator "/usr/bin/$latest_terminal"
echo "x-terminal-emulator set to $latest_terminal."
else
echo "Current default x-terminal-emulator is not xterm. Exiting
Output:
lxterminal: 10. Okt
xfce4-terminal not found.
mate-terminal not found.
uxterm: 2. Dez
xterm: 2. Dez
urxvt not found.
konsole not found.
terminator not found.
gnome-terminal not found.
gnome-terminal.wrapper not found.
qterminal not found.
tilix.wrapper: 3. Dez
Latest x-terminal-emulator:
lrwxrwxrwx 1 root root 14 3. Dez 17:10 /etc/alternatives/x-terminal-emulator -> /usr/bin/xterm
Latest standard terminal emulator is tilix.wrapper.
update-alternatives: /usr/bin/tilix.wrapper wird verwendet, um /usr/bin/x-terminal-emulator (x-terminal-emulator) im manuellen Modus bereitzustellen
x-terminal-emulator set to tilix.wrapper.
Will test this a bit more
PiGro now recognizes when xterm
is set as default and displays this message at startup. I hope that this is a pleasant solution.
This is fine, but it seems much more complicated than necessary. Take a look at this potential change to the pi-apps install script for PiGro:
#!/bin/bash
version=23.04
# remove legacy folders/files if present
rm -rf ~/PiGro-Aid-
rm -f ~/Desktop/pigro.desktop ~/.local/share/applications/pigro.desktop
#prevent lxterm dependency from becoming default terminal
default_terminal="$(readlink -f /usr/bin/x-terminal-emulator)"
install_packages https://github.com/actionschnitzel/PiGro-Aid-/releases/download/${version}/pigro-jci-${version}.deb || exit 1
#check if terminal choice was changed after pigro was installed
if [ ! -z "$default_terminal" ] && [ "$(readlink -f /usr/bin/x-terminal-emulator)" != "$default_terminal" ];then
#restore previous choice
sudo update-alternatives --set x-terminal-emulator "$default_terminal"
fi
I think I will upload this change to pi-apps from my end, but did you consider an approach like this one?
Wow, that's really much easier. I did it with 230 lines of code. Way too complicated. If it's ok I'll play a bit with your approach and try to incorporate it into the DEBIAN package.
Wow, that's really much easier. I did it with 230 lines of code. Way too complicated. If it's ok I'll play a bit with your approach and try to incorporate it into the DEBIAN package.
Sure go ahead. The only difficulty you may encounter is how to store the original value of $default_terminal that was set with the preinst
script, for the postinst
script to read. I am not sure if variables exported by the scripts are preserved. If not, you could use a temporary file to store the value of $default_terminal for the postinst
script to read.
If not, you could use a temporary file to store the value of $default_terminal for the
postinst
script to read.
That was exactly my idea.
Would you be interested in taking a look at the current development state of 24.01? A second opinion would be really good.
These are the installation commands for my developer branch:
sudo apt install git xterm python3-pil python3-pil.imagetk python3-psutil python3-distro python3-bs4 python3-dev python3-requests mpg123 lolcat wmctrl gdebi mousepad
git clone -b dev https://github.com/actionschnitzel/PiGro-Aid-.git
#The program icon must currently be copied manually:
sudo cp ~/PiGro-Aid-/images/icons/logo.png /usr/share/icons/hicolor/256x256/apps/pigro-logo.png
python3 ~/PiGro-Aid-/src/main.py
I tried your latest dev branch now.
sudo_popup
function.
sudo_popup() { #just like sudo on passwordless systems like PiOS, but displays a password dialog otherwise. Avoids
displaying a password prompt to an invisible terminal.
if sudo -n true; then
# sudo is available (within sudo timer) or passwordless
sudo "$@"
else
# sudo is not available (not within sudo timer)
pkexec "$@"
fi
}
etc/terminal-run
script does?wget -qO- https://raw.githubusercontent.com/Botspot/pi-apps/master/apps/More%20RAM/install | bash
For uninstall:
wget -qO- https://raw.githubusercontent.com/Botspot/pi-apps/master/apps/More%20RAM/uninstall | bash
I mention this because you could make a More RAM button appear for users without pi-apps installed.
Thank you for your feedback. It shows me that many of the changes I thought were good are not so good. I have noted all your comments and will implement them.
The theming options are all greyed out even though I am using default Raspberry Pi Bullseye. It seems like these options should be usable if they work on Bookworm X11.
I have problems with both Wayfire and X11. Under X11, there was a bug that caused the window decoration to change without reason when setting an icon theme. This couldn't be reverted. I will continue testing and working on it. Lately, my focus in the Look & Feel tab
has been more on Ubuntu/Mate and Xfce.
Recommended Software / One Click
Recommended Software is not finished yet. I intended to merge theOne Click tab
with the Nice 2 Have tab
. Since you're asking where the One Click tab
went, I infer that you liked it. I'm not so sure anymore if I want to proceed with that direction. ReincorporatingOne Click
and Nice 2 Have
is not a big task. Most of the time, I have invested in making PiGro modular in its file structure. This way, I can now add tabs more quickly.
Why do some root actions require me to enter a password, but others like FM God Mode do not?
I had decided to go completely with pkexec but found out that only sudo works with pcmanfm. This is currently a temporary solution. Earlier versions had if
/else
statements for PiOS (sudo
) and Ubuntu (pkexec
). I will reintroduce that. The idea behind executing everything that requires elevated privileges with pkexec
was to emphasize that the user is now able to make significant changes to the system.
In System, the Raspi Appearance Settings and Raspi Desktop settings buttons seem to both launch the exact same tool.
Will be changed
Does your dialog library allow setting tooltips? It would be much easier to understand things if hovering the mouse over a button would display a short explanation.
Yes, in the Update tab, the APT buttons should have tooltips. However, I will also add tooltips for all the other buttons.
"Tidy Up Unuesed" is misspelled. It should be "Tidy Up Unused".
Will be fixed
ZRAM
Good to know that it works without Pi-Apps as well. I haven't had the opportunity to implement that function yet.
Recommended Software / One Click
Recommended Software is not finished yet. I intended to merge the
One Click tab
with theNice 2 Have tab
. Since you're asking where theOne Click tab
went, I infer that you liked it. I'm not so sure anymore if I want to proceed with that direction. ReincorporatingOne Click
andNice 2 Have
is not a big task. Most of the time, I have invested in making PiGro modular in its file structure. This way, I can now add tabs more quickly.
This is understandable. I thought your choices in the One Click had good taste, so when I noticed it gone I was mostly just curious if/where you were planning to move it.
I have problems with both Wayfire and X11. Under X11, there was a bug that caused the window decoration to change without reason when setting an icon theme. This couldn't be reverted. I will continue testing and working on it. Lately, my focus in the Look & Feel tab has been more on Ubuntu/Mate and Xfce.
This is because the mutter WM on Bullseye is actually themed by the active GTK theme. So is the lxpanel. It's pretty easy to copy over the window border stuff to another theme and then adjust the style to match the rest of the theme. I made an entire Windows 11 theme for Bullseye but disk corruption wiped it clean. The experience was too painful to repeat all that work. But it can be done.
Sure go ahead. The only difficulty you may encounter is how to store the original value of $default_terminal that was set with the
preinst
script, for thepostinst
script to read. I am not sure if variables exported by the scripts are preserved. If not, you could use a temporary file to store the value of $default_terminal for thepostinst
script to read.
I updated my DEBIAN-BUILD-SCRIPT. This solution, as far as I can see, has worked.
cat > ~/PIGRO-DEBIAN-BUILD-BOX/debian/DEBIAN/preinst << 'EOF'
#!/bin/bash
# preinst script
# Save the path of the standard terminal in a temporary file
default_terminal=$(readlink -f /usr/bin/x-terminal-emulator)
echo "$default_terminal" > /tmp/default_terminal_path
EOF
cat > ~/PIGRO-DEBIAN-BUILD-BOX/debian/DEBIAN/postinst << 'EOF'
#!/bin/bash
# postinst script
# Read the saved path from the temporary file
default_terminal_path=$(cat /tmp/default_terminal_path)
# Check and restore the path
if [ ! -z "$default_terminal_path" ] && [ "$(readlink -f /usr/bin/x-terminal-emulator)" != "$default_terminal_path" ]; then
# Restore the previous selection
update-alternatives --set x-terminal-emulator "$default_terminal_path"
fi
# Clean up: Remove temporary file
rm -f /tmp/default_terminal_path
EOF
This is because the mutter WM on Bullseye is actually themed by the active GTK theme. So is the lxpanel. It's pretty easy to copy over the window border stuff to another theme and then adjust the style to match the rest of the theme. I made an entire Windows 11 theme for Bullseye but disk corruption wiped it clean. The experience was too painful to repeat all that work. But it can be done.
This morning there was a nice surprise. I found PiXnoir
in the theme folder after an update. That's a completely new approach that I can work with.
Are you manually embedding screenshots of some apps? I am curious how that works: if you are capturing these screenshots yourself or if you are finding images online.
I took the screenshots of Pi apps myself ... 200 ... :-( ... still in the worx https://github.com/actionschnitzel/PiGro-Aid-/tree/data/screenshots/pi-apps
All others are extracted with https://pypi.org/project/beautifulsoup4/. That was no fun because I have no idea about HTML. I really wanted to know how it works in Linux Mint and read through the whole mintinstall.py. https://github.com/linuxmint/mintinstall/blob/master/usr/lib/linuxmint/mintinstall/mintinstall.py#L297
I also tried to get the information via appsteam, but I would have to completely rewrite the way Software_Tab works.
My Solution (not perfect) For DEB:
def apt_screenshot():
try:
apt_app = str(apt_entry.get())
url = f"https://screenshots.debian.net/package/{apt_app}#gallery-1"
# Make an HTTP GET request to the webpage
response = requests.get(url)
# Use BeautifulSoup to parse the HTML
soup = BeautifulSoup(response.text, "html.parser")
# Find all links with .png extension
links = [
link.get("href")
for link in soup.find_all("a")
if link.get("href").endswith(".png")
]
url_output = f"https://screenshots.debian.net{str(links[1])}"
with urlopen(url_output) as url_output:
self.app_img = Image.open(url_output)
self.app_img = resize(self.app_img)
self.app_img = ImageTk.PhotoImage(self.app_img)
panel.config(image=self.app_img)
except IndexError as e:
print(f"{e}")
panel.config(image=self.no_img)
For Flatpak:
def get_flatpak_screenshot():
url = (
f"https://flathub.org/apps/{Flat_remote_dict[flatpak_entry.get()]}"
)
try:
# Die URL der Webseite
# url = "https://flathub.org/de/apps/de.k_bo.Televido"
# Der zu suchende Teilinhalt
desired_content = f"https://dl.flathub.org/repo/screenshots/{Flat_remote_dict[flatpak_entry.get()]}-stable/752x423/"
# Die Webseite herunterladen
web_content = requests.get(url).text
# Verwenden von re (regulären Ausdrücken), um die gewünschte URL zu extrahieren
match = re.search(rf'({desired_content}[^"\s]+)', web_content)
# Überprüfen, ob der gewünschte Inhalt gefunden wurde
if match:
extracted_url = match.group(1)
print("Gefundener Teilinhalt:", extracted_url)
og_image_content = extracted_url
# return og_image_content
with urlopen(og_image_content) as url_output:
self.img = Image.open(url_output)
self.img = resize(self.img)
self.img = ImageTk.PhotoImage(self.img)
flatpak_panel.config(image=self.img)
else:
print("No og:image meta property found.")
flatpak_panel.config(self.no_img)
except requests.exceptions.RequestException as e:
print("Error fetching URL:", e)
return None
PiGro appears to use x-terminal-emulator as all other programs do, but for some reason PiGro also lists xterm as a required dependency. Why is that? I personally don't like installing xterm, because whenever a new terminal is installed,
update-alternatives
will switch to treat the new terminal as user-preferred. Meaning that on fresh PiOS, before installing PiGro, opening a terminal means you get the nicelxterminal
which is fast, easy to read, well-themed, and supports copy-and-paste. But after installing PiGro, now the rest of the system will use xterm, which uses a much smaller font, is not themed well, does not support clipboard...Have you considered using something like the pi-apps
terminal-run
script instead? Terminal-run is special in that it supports the user's choice of terminal, but allows you to run newline-separated lists of commands while setting the terminal title. https://github.com/Botspot/pi-apps/blob/master/etc/terminal-run