Botspot / pi-apps

Raspberry Pi App Store for Open Source Projects
GNU General Public License v3.0
1.96k stars 202 forks source link

New Pi-Apps GUI #1578

Closed Botspot closed 2 years ago

Botspot commented 2 years ago

Hey everyone, Discord seems to be down at the moment, so we'll chat here.

I think the new Pi-Apps interface is complete, but it's best for several eyes to look at it before I upload changes to nearly every major script. ~~Attached is a zip file of my Pi-Apps directory (I took out the .git and data/status folders) pi-apps.zip Extract the zip anywhere you want, and give it a spin!~~ theofficialgman edit: I suggest cloning from the PR into another folder like the /tmp folder:

cd /tmp
rm -rf /tmp/pi-apps
git clone https://github.com/Botspot/pi-apps.git
cd pi-apps
git checkout new-gui
# run the gui
./gui

The PR can be found here: https://github.com/Botspot/pi-apps/pull/1580

Feedback appreciated. This new script design is substantially more complicated than all previous versions of the gui script, so there may be bugs in the flow of dialog windows. In addition to YAD's behavior being changed to a dual-pane layout with integrated list-refreshing, I've also rewritten the xlunch implementation to allow integrated list-refreshing. (avoiding having to close and re-open xlunch when selecting a category)

Pinging a few contributors who might be interested in testing it: @theofficialgman @cycool29 @Itai-Nelken @ryanfortner @mobilegmYT @CleanMachine1 @Jai-JAP @amirdahan

Edit: a previous version of the zip had DIRECTORY hard-coded to ~/pi-apps. It has since been fixed.

Sussy-OS commented 2 years ago

@Botspot 1st of all, I like the gui, though I feel like it is formatted weirdly (looks tiny in comparison to current GUI) image a̶n̶d̶ ̶w̶h̶e̶n̶ ̶I̶ ̶t̶r̶y̶ ̶t̶o̶ ̶c̶l̶i̶c̶k̶ ̶o̶n̶ ̶a̶n̶y̶t̶h̶i̶n̶g̶,̶ ̶i̶t̶ ̶e̶x̶p̶o̶r̶t̶s̶:̶ ̶̶e̶n̶v̶:̶ ̶‘̶.̶/̶g̶u̶i̶’̶:̶ ̶N̶o̶ ̶s̶u̶c̶h̶ ̶f̶i̶l̶e̶ ̶o̶r̶ ̶d̶i̶r̶e̶c̶t̶o̶r̶y̶̶ (I found the fix, but it is weird, you can't cd into the directory, and run the gui file, you have to run it from the home directory.) and 2nd of all, could you please add me to the list of people to ping with test builds? I would greatly appreciate that.

Sussy-OS commented 2 years ago

I don't really like the width of the new Pi-Apps GUI, do you think you could make it a little wider?

theofficialgman commented 2 years ago
Timestamps don't match
original file: /home/pi/pi-apps/apps 1646761906 1646759968.1355262890 /home/pi/pi-apps/apps/Conky/description
/home/pi/pi-apps/data/settings 1646417459 1646761826.8195941340 /home/pi/pi-apps/data/settings/Shuffle App list
/home/pi/pi-apps/data/status 1646530925 1646766668.7320171270 /home/pi/pi-apps/data/status/btop++
/home/pi/pi-apps/etc 1646762308 1646762308.6289543710 /home/pi/pi-apps/etc/preload-daemon
/home/pi/pi-apps/icons/categories 1638374705 1638374705.2131248370 /home/pi/pi-apps/icons/categories/Imported.png
/home/pi/pi-apps/apps 1646761906 1646759968.1355262890 /home/pi/pi-apps/apps/Conky/description
/home/pi/pi-apps/preload 1646762895 
/home/pi/pi-apps/api 1646766313 
/home/pi/pi-apps/data/category-overrides  
new timestamp: /tmp/pi-apps/apps 1646761906 1646759968.0000000000 /tmp/pi-apps/apps/Conky/website
/tmp/pi-apps/data/settings 1646417459 1646761826.0000000000 /tmp/pi-apps/data/settings/Shuffle App list
/tmp/pi-apps/data/status 1646530925 /tmp/pi-apps/etc 1646762308 1646762308.0000000000 /tmp/pi-apps/etc/preload-daemon
/tmp/pi-apps/icons/categories 1638374705 1638374705.0000000000 /tmp/pi-apps/icons/categories/Imported.png
/tmp/pi-apps/apps 1646761906 1646759968.0000000000 /tmp/pi-apps/apps/Conky/website
/tmp/pi-apps/preload 1646771853 
/tmp/pi-apps/api 1646766313 
/tmp/pi-apps/data/category-overrides  
Generating list...

timestamping.... guess I will need to look at the zip and see what you changed (fyi, I did not put mine at /pi/pi-apps, I put it in /tmp/pi-apps)

theofficialgman commented 2 years ago

also yeah.. it doesn't work because of this error env: ‘./gui’: No such file or directory that Sussy-OS already showed

theofficialgman commented 2 years ago

Screenshot from 2022-03-08 19-10-21 😆 looks like everything is working nicely (not). its running a new instance the pi-apps version from my home directory every time I click on an option regardless of where I put the new one...

theofficialgman commented 2 years ago

ah right.. simple fix. you needed to add the directory variable

      --dclick-action=true --select-action "env pipe=$pipe geometry2=$geometry2 '${DIRECTORY}/$0'" \
      --button="!${DIRECTORY}/icons/search.png!Search":"env pipe=$pipe geometry2=$geometry2 '${DIRECTORY}/$0' '' '' Search/ Search/" \
      --button="!${DIRECTORY}/icons/options.png":2 \

side by side windows do not work for me new windows always pop up in the top left

theofficialgman commented 2 years ago

oh LOL, yeah never do this botspot xrandr_out="$(xrandr | grep "HDMI-1" | awk '{print $4}' | tr 'x+' ' ')" thats guaranteed to pretty much never work

Botspot commented 2 years ago

ah right.. simple fix. you needed to add the directory variable

      --dclick-action=true --select-action "env pipe=$pipe geometry2=$geometry2 '${DIRECTORY}/$0'" \
      --button="!${DIRECTORY}/icons/search.png!Search":"env pipe=$pipe geometry2=$geometry2 '${DIRECTORY}/$0' '' '' Search/ Search/" \
      --button="!${DIRECTORY}/icons/options.png":2 \

Strange. If being run from an absolute path, the $0 variable should also be an absolute path.

theofficialgman commented 2 years ago

getting the output from Screen 0 is safe and "should" work everywhere some example outputs:

Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384
DSI-0 connected (normal left inverted right x axis y axis)
   720x1280      60.00 +
DP-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 480mm x 270mm
   1920x1080     60.00*+  59.95    50.00  
   1280x1024     75.03    60.00  
   1280x720      60.00    59.94    50.00  
   1152x864      75.00  
   1024x768      75.03    60.01  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       59.94  
   720x400       70.04  
   640x480       75.00    59.94    59.94
 Screen 0: minimum 8 x 8, current 1280 x 720, maximum 16384 x 16384
DSI-0 connected primary 1280x720+0+0 left (normal left inverted right x axis y axis) 0mm x 0mm
   720x1280      60.00*+
DP-0 disconnected (normal left inverted right x axis y axis)
theofficialgman commented 2 years ago

ah right.. simple fix. you needed to add the directory variable

      --dclick-action=true --select-action "env pipe=$pipe geometry2=$geometry2 '${DIRECTORY}/$0'" \
      --button="!${DIRECTORY}/icons/search.png!Search":"env pipe=$pipe geometry2=$geometry2 '${DIRECTORY}/$0' '' '' Search/ Search/" \
      --button="!${DIRECTORY}/icons/options.png":2 \

Strange. If being run from an absolute path, the $0 variable should also be an absolute path.

yeah we aren't running from an absolute path, launched it with ./gui from the folder as was allowed before

Botspot commented 2 years ago

yeah we aren't running from an absolute path, launched it with ./gui from the folder as was allowed before

Should be easy to fix then. Every mention of "$0" should be changed to "$DIRECTORY/gui" and then it should work.

theofficialgman commented 2 years ago

@Botspot this should be suitable

  #determine screen_width and screen_height
  screen_dimensions="$(xdpyinfo | grep "dimensions" | awk '{ print $2 }' | tr 'x+' ' ')"
  screen_width="$(awk '{print $1}' <<<"$screen_dimensions")"
  screen_height="$(awk '{print $2}' <<<"$screen_dimensions")"
  unset screen_dimensions
Botspot commented 2 years ago

@Botspot this should be suitable

  screen_dimensions="$(xdpyinfo | grep "dimensions" | awk '{ print $2 }' | tr 'x+' ' ')"

The problem with using xpdyinfo is that people with dual displays encountered problems. See: https://github.com/Botspot/pi-apps/issues/172

cycool29 commented 2 years ago

pi-apps.zip

Nice! BTW the app info window should be closed when opening settings.

Botspot commented 2 years ago

Nice! BTW the app info window should be closed when opening settings.

Could you make a screen recording? In my desktop environment, the app Details windows automatically closes when it is no longer focused.

theofficialgman commented 2 years ago

@Botspot this should be suitable

  screen_dimensions="$(xdpyinfo | grep "dimensions" | awk '{ print $2 }' | tr 'x+' ' ')"

The problem with using xpdyinfo is that people with dual displays encountered problems. See: #172

ok then use xrandr but grep this output from it: Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384 works perfectly fine with dual screens

theofficialgman commented 2 years ago

@Botspot this should be fine, we don't really care output the garbage output after the resolutions:

  screen_dimensions="$(xrandr | grep "Screen 0:" | sed -n -e 's/^.*current //p' | tr 'x+' ' ' | tr ',+' ' ')"
  screen_width="$(awk '{print $1}' <<<"$screen_dimensions")"
  screen_height="$(awk '{print $2}' <<<"$screen_dimensions")"
  unset screen_dimensions
theofficialgman commented 2 years ago

hmm... actually heck this also has the same issues.

give me a bit and I'll find something that works everywhere

theofficialgman commented 2 years ago

going to take the code from neofetch here and massage it a bit

https://github.com/dylanaraps/neofetch/blob/ccd5d9f52609bbdcd5d8fa78c4fdb0f12954125f/neofetch#L3082-L3115

  screen_dimensions="$(xrandr --nograb --current |  awk -F 'connected |\\+|\\('  '/ connected.*[0-9]+x[0-9]+\+/ && $2 {printf $2 ", "}' | sed -n -e 's/^.*primary //p' | tr 'x+' ' ' | tr ',+' ' ')"
  screen_width="$(awk '{print $1}' <<<"$screen_dimensions")"
  screen_height="$(awk '{print $2}' <<<"$screen_dimensions")"
  unset screen_dimensions

this "should" work on both single and multi-monitors, with the primary monitor resolution returned. yes I have tested on a multi-monitor setup without issues

theofficialgman commented 2 years ago

another issue to report, right clicking in the popup windows (or clicking in the title bar) causes it to close these are actions that should be allowed (for example right clicking so a user can copy links out of an apps description)

do you think you could open a PR for this? it would be easier to track. just make another branch for it in the repo here and you can open a PR from it to master. I can open it for you if you want

Botspot commented 2 years ago

another issue to report, right clicking in the popup windows (or clicking in the title bar) causes it to close these are actions that should be allowed (for example right clicking so a user can copy links out of an apps description)

I'm not sure how much can be done, as this is using yad's --close-on-unfocus flag.

just make another branch for it in the repo here

New branch has been added: https://github.com/Botspot/pi-apps/tree/new-gui Does it really make sense to open a PR at this time?

theofficialgman commented 2 years ago

New branch has been added: https://github.com/Botspot/pi-apps/tree/new-gui Does it really make sense to open a PR at this time?

yes, draft PRs are a thing and make it much easier to track issues (we can comment on changes desired and then those can be automatically included by clicking the add commit button)

I went ahead and opened one to document stuff: https://github.com/Botspot/pi-apps/pull/1580

Sussy-OS commented 2 years ago

Hi, @Botspot I've been tracking this issue on my PW 4, and I just now got on my pi. I was wondering, should we mainly talk on this issue, or on @theofficialgman 's draft pull?

Botspot commented 2 years ago

Hi, @Botspot I've been tracking this issue on my PW 4, and I just now got on my pi. I was wondering, should we mainly talk on this issue, or on @theofficialgman 's draft pull?

It doesn't really matter. I guess discussion about particular code bits would make more sense on the pull, and general comments/suggestions can be made either here or there.

Sussy-OS commented 2 years ago

It doesn't really matter. I guess discussion about particular code bits would make more sense on the pull, and general comments/suggestions can be made either here or there.

Okay, that makes sense. Thanks.

Crilum commented 2 years ago

I'm not a huge fan of the new GUI, it's just too narrow, and I like being able to install/uninstall apps without opening the description. :) I do kind of like the side by side thing though.

The app list also doesn't work at all on my system (RPiOS 11) :

https://user-images.githubusercontent.com/91354257/157560960-21a30a58-48e3-410e-8343-21816eeabb85.mp4

Search works though, and you can view apps from there..

Also, I don't think the Multi-Install button is in the right place, it just seems kind of weird in the Settings.

theofficialgman commented 2 years ago

The app list also doesn't work at all on my system (RPiOS 11) :

@Crilum thats also the error I was getting before I commited the change about an hour ago can you do a git pull and make sure its not gone?

Crilum commented 2 years ago

@theofficialgmanI did a pull just now, git says everything is up to date.

theofficialgman commented 2 years ago

ok... yeah there are actually quite a few bugs if I keep the color set to nothing, it just overwrites the text color as I move my mouse over it with whatever color happens to actually be set (so if there is green text and if I hover over it, then move over other text that changes as well)

theofficialgman commented 2 years ago

@Crilum pull again now. I enabled some things for testing

Crilum commented 2 years ago

@theofficialgman it works now

theofficialgman commented 2 years ago

ok so I see why botspot changed it to $3 then... there are differences between your echo command and mine yours isn't printing a newline on the empty character (but it should be) mine is

let me try a workaround

Crilum commented 2 years ago

Hmm. I've always found echo to be simple, but not very smart... lol

theofficialgman commented 2 years ago

@Crilum ok pull and then try again if it doesn't work, I want you to the send your LIST- file here (in data/preload)

Crilum commented 2 years ago

What doesn't work? The app list works now, after you said:

@Crilum pull again now. I enabled some things for testing

theofficialgman commented 2 years ago

What doesn't work? The app list works now, after you said:

@Crilum pull again now. I enabled some things for testing

we can't do what I did for that commit... I manually set the color of text to white which "fixed" it (but that won't work for light themes). just try again now

theofficialgman commented 2 years ago

@Crilum ok I so force pushed some changes. delete your testing repo and re-clone it and try again please. if it doesn't work, please send the contents of your data/preload folder here

theofficialgman commented 2 years ago

for reference this is what LIST- should generate like:


/tmp/pi-apps/icons/categories/All Apps.png
All Apps
All Apps/
App folder

/tmp/pi-apps/icons/categories/Appearance.png
Appearance
Appearance/
App folder

/tmp/pi-apps/icons/categories/Editors.png
Editors
Editors/
App folder

(spaces are blank color definitons) and this is LIST-All Apps


/tmp/pi-apps/icons/back.png
Back
/
Return to the previous location

/tmp/pi-apps/apps/Alacritty Terminal/icon-24.png
Alacritty Terminal
All Apps/Alacritty Terminal
A fast, cross-platform, OpenGL terminal emulator

/tmp/pi-apps/apps/All Is Well/icon-24.png
All Is Well
All Apps/All Is Well
ALL IS WELL is a bash script that allows users to easily update and upgrade their repositories and packages on linux.

anything different will break the format and you get issues...

theofficialgman commented 2 years ago

alright... so turns out is its not echo thats broken... its redirection. hence why some OSs get this as output:

1
2
3 Appearance
4 Appearance/

and others get this:

1
2 Appearance
3 Appearance/
4 App folder
theofficialgman commented 2 years ago

ok... so here is the bug this is what pi-apps yad looks like: --column=@fore@:hd --column=:IMG --column=Name --column=Sysname:HD --column=tip:HD

according to yad: Special column names @fore@, @back@ and @font@ sets corresponding rows attributes. Values of those columns don't show in results. so the color should be hidden from the output, right? NOPE

1 #00AA00
2 

gosh yad.... fix your docs. even worse there is a bug on top of this

newer yad is combining two null outputs into one.... the .png evaluates to a null output (yeah it outputs null no matter what the png location was), and if the color is not passed in, also evaluates to a null output. this is why if we manually set the color everything starts working, because it doesn't remove all null outputs, it just combines neighboring ones into one.

older yad does not have this bug, it outputs the same number of arguments no matter if they are null or not.

the workaround you ask? either A: always set the color (which is probably necessary already since not setting it has bugs already described by me here: https://github.com/Botspot/pi-apps/issues/1578#issuecomment-1063529483)

or B:change the order of the columns and the preload lists so there are never two null outputs next to each other

theofficialgman commented 2 years ago

I've implemented option B: (order is now: --column=:IMG --column=Name --column=Sysname:HD --column=tip:HD --column=@fore@:HD )but as I said.. at least on my version of yad, there is a bug where names change colors as the mouse drags over them

https://user-images.githubusercontent.com/28281419/157590653-fb87e7bc-a334-4367-9a24-6fa689aababd.mp4

browser is crap and doesn't want to play the video, just wget the link to see the problem https://user-images.githubusercontent.com/28281419/157590653-fb87e7bc-a334-4367-9a24-6fa689aababd.mp4

if you explicitly tell it what color to use (like when I tested and set it to white) this does not happen

theofficialgman commented 2 years ago

now, in order to fix this bug we need to set the color. which means we need to get what the default color "should" be

this can be accomplished with a simple python script (it doesn't appear there are any gtk bindings for bash)

#!/usr/bin/env python3
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
win = Gtk.Window()
vb = Gtk.VBox()
tv = Gtk.TextView()
vb.add(tv)
win.show_all()
style = tv.get_style_context()
textcolor = style.get_color(Gtk.StateType.NORMAL) 
print(Gdk.RGBA.to_string(textcolor))

for my theme (a dark one) it returns pure white rgb(255,255,255) I've tested setting a lite theme as well and it returns darker text rgba(21,22,28,0.85)

this output can be put straight into yad

theofficialgman commented 2 years ago

alright fixed with https://github.com/Botspot/pi-apps/pull/1580/commits/21890b3afde73b2d3b358ac097c7e9eaef6956d0

if anyone has a better way of getting from pure bash, let me know. but I think python or compiled C/C++ code are the only options here

Botspot commented 2 years ago

if anyone has a better way of getting from pure bash, let me know. but I think python or compiled C/C++ code are the only options here

A while back, I made a light/dark theme detection script with some help from @cycool29. After some further modifications, here it is:

#color could have been manually set by lxsession. If so, the workflow is shorter:
font_color=$(cat $HOME/.config/lxsession/$DESKTOP_SESSION/desktop.conf | grep 'text_color:........' -oh | sed 's/.*://g' | grep '.......' -o | head -n1)

if [ -z "$font_color" ];then

  theme_name=$(cat $HOME/.config/lxsession/$DESKTOP_SESSION/desktop.conf | grep 'sNet/ThemeName' | sed s+sNet/ThemeName=++g | sed s/'"'//g || cat $HOME/.config/gtk-3.0/settings.ini | grep 'gtk-theme-name=' | sed s/'gtk-theme-name='//g | sed s/'"'//g || cat $HOME/.gtkrc-2.0 | grep 'gtk-theme-name=' | sed s/'gtk-theme-name='//g | sed s/'"'//g )

  if [ -d "$HOME/.themes/$theme_name" ]; then
    theme_dir="$HOME/.themes/$theme_name"
  elif [ -d "/usr/share/themes/$theme_name" ]; then
    theme_dir="/usr/share/themes/$theme_name"
  fi

  font_color=$(find "$theme_dir" -name gtk.css | xargs grep -h '@define-color text_color #' | sed 's/@define-color text_color //g' | sed 's/;.*//g' | head -n1)

  if [ -z "$font_color" ];then
    font_color=$(find "$theme_dir" -name themerc | xargs grep -h 'window.active.label.text.color:........' -o | sed s/"window.active.label.text.color: #"//g | sed 's/ //g' | head -n1)
  fi

  if [ -z "$font_color" ]; then
    font_color=$(find "$theme_dir" -name gtkrc | xargs grep 'text_color:........' -oh | sed 's/.*://g' | grep '.......' -o | head -n1)
  fi

  if [ -z "$font_color" ]; then
    font_color=$(find "$theme_dir" -name gtkrc | xargs grep -h "text.NORMAL." | grep -o '".*"' | tr -d '"' | head -n1)
  fi
fi

echo $font_color
theofficialgman commented 2 years ago

if anyone has a better way of getting from pure bash, let me know. but I think python or compiled C/C++ code are the only options here

A while back, I made a light/dark theme detection script with some help from @cycool29. After some further modifications, here it is:

I appreciate the response botspot, but that won't work at all. for one, it requires LXDE (aka the lxsession folder) which is definitly not a given. for two, your script won't detect if the user has set the GTK theme using the export option (like you can set via pi-apps settings https://github.com/Botspot/pi-apps/blob/21890b3afde73b2d3b358ac097c7e9eaef6956d0/api#L2108-L2122).

the python script has neither of these issues since it actually gets the GTK theme text color (white, grey, black, whatever rgba color the theme specifies) and should be safe as all systems likely have python (2 or 3, it doesn't matter), installed by default with their OS. Worst case you don't have it and the color is set to nothing like before

Botspot commented 2 years ago

I appreciate the response botspot, but that won't work at all. for one, it requires LXDE (aka the lxsession folder) which is definitly not a given.

Not quite. The bash-based detection script also checks for settings in $HOME/.config/gtk-3.0/settings.ini and $HOME/.gtkrc-2.0, so lxsession is not required.

for two, your script won't detect if the user has set the GTK theme using the export option (like you can set via pi-apps settings

That would be very easy to fix.

theofficialgman commented 2 years ago

Not quite. The bash-based detection script also checks for settings in $HOME/.config/gtk-3.0/settings.ini and $HOME/.gtkrc-2.0, so lxsession is not required.

I have neither of these alternative files.... so your bash script fails. the python script however has no issues

Botspot commented 2 years ago

Let's take a step back: we're trying to avoid triggering a bunch of harmless GTK warnings when no color is given in yad. But this only occurs with outdated yad in an outdated OS. Stretch, Buster, and Bullseye users won't encounter this problem. Is it worth fixing? Perhaps it would be easier to update yad on older OS'es like yours.

theofficialgman commented 2 years ago

Let's take a step back: we're trying to avoid triggering a bunch of harmless GTK warnings when no color is given in yad. But this only occurs with outdated yad in an outdated OS. Stretch, Buster, and Bullseye users won't encounter this problem. Is it worth fixing? Perhaps it would be easier to update yad on older OS'es like yours.

its not the warning that is the problem. its this that is the real issue: https://user-images.githubusercontent.com/28281419/157590653-fb87e7bc-a334-4367-9a24-6fa689aababd.mp4 (if that won't play in the web browser, download it and play it locally)

Botspot commented 2 years ago

Let's take a step back: we're trying to avoid triggering a bunch of harmless GTK warnings when no color is given in yad. But this only occurs with outdated yad in an outdated OS. Stretch, Buster, and Bullseye users won't encounter this problem. Is it worth fixing? Perhaps it would be easier to update yad on older OS'es like yours.

its not the warning that is the problem. its this that is the real issue: https://user-images.githubusercontent.com/28281419/157590653-fb87e7bc-a334-4367-9a24-6fa689aababd.mp4

I saw the video. Again, that doesn't occur on yad 0.40.0, so therefore it won't occur in the past three debian versions. I'm not sure how many people use Pi-Apps on Ubuntu 18, but probably not that many. This python thing could be considered a "hacky fix", so perhaps it would be better to implement an alternative "hacky fix" that simply updates yad to 0.40.0?