Tomas-M / xlunch

Graphical app launcher for X with minimal dependencies
http://xlunch.org
GNU General Public License v3.0
219 stars 37 forks source link

Create deb installer #48

Open saymoncoppi opened 6 years ago

saymoncoppi commented 6 years ago

Hello! Do you think to make something like: - Create categories for apps (similar deepin launcher), maybe get some ideas from menulibre - Change fonts to Noto or allow the user to change

I really like your job! congrats!!!

PMunch commented 6 years ago

You can already change fonts, and categories can easily be implemented by using either recur or a wrapper script (see the web-site for more info). Or did you have something else in mind for the categories (never tried Deepin launcher).

A .deb installer would be good though. Might look into that at some point.

PMunch commented 6 years ago

Added the option to create arbitrary buttons anywhere on the screen in https://github.com/Tomas-M/xlunch/commit/a170ccbb0e0cff65bf1c355b319c18f989ff0b2f, this means you can have another way of creating categories which would look more like deepin.

linuxslide commented 6 years ago

Hello Peter and Thomas! I'm working on a script to make a basic setup for xlunch, adding: themes for logout and launcher menu, translations and other tiny improvments to easely deploy. I guess one more day and I'll commit on github. So I could move to next step (packing aa deb file). I'll do that asap.

But backing to category subject, I'd like to suggest a new feature to group apps by the main category. Adding an icon, category name and a horizontal line. just it!

Checking the *.desktop files, each of them have a Category entry compatible with the freedesktop standards. So the question is "Could we include a parameter to choose group or not the apps using this categories?"

The default category names are listed below:

https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry

Another thing that im working is the xlunch_genquick script, to get the default icon theme and accept the svg files from modern themes.

Gimme ano more day (night to be honest lol)

Best regards. Congratulations for the excelent job! deepin screenshot_selecionar area_20180719013428

saymoncoppi commented 6 years ago

Hey guys! I posted as linuxslide the last comment, sorry...

Check this: https://github.com/saymoncoppi/xlunchr and tell me what do you think about.

PMunch commented 6 years ago

Hi @saymoncoppi/@linuxslide! xlunchr looks great, but I'm not sure why you made it a separate repo? I'm all for adding it here if Tomas would like to :) But why aren't you using the default genentries script? Now we have three solutions to getting an entries list..

I've been thinking about categories for a while, and unfortunately they would break the icon alignment stuff.. And since we don't have smooth scrolling that's not trivial to work around (unless we force the category separators to take up a full line). But what you have in the above image can sorta be done in xlunch. Have one menu with all entries, and a separate entries file for each category. Then add the category buttons along the edge with a recur command that would relaunch xlunch with that categories entries file.

saymoncoppi commented 6 years ago

Hello Peter! Tks for the answer. I created this repo only to show you ideias and scripts. Im able to close it no problem.

About the genentries, I made changes but you could add in your project easlily.

Detect default icon pack: ICONTHEME=$(cat ~/.gtkrc-2.0 | grep gtk-icon-theme-name= | sed -e "s/^gtk-icon-theme-name=//" |sed 's/["]//g')

I made this bc the original script only get icons from /usr/share/icons/hicolor /usr/share/pixmap Due the new structure of themes (icons packs) the original one cant get subfolder /apps/


Before this, due Imlib dont load svg files, so I made a tiny workaround:

if [[ $Icon =~ ".png" ]] || [[ $Icon =~ ".xpm" ]]; then echo "$Name;$Icon;$Exec;" 2>/dev/null 1>>/etc/xlunch/entries.dsv else Iconsource=$ICONPATH$Icon".svg" Icondestiny="/usr/share/xlunch/icons/entries/"$Icon".png" convert -density 1536 -background none -resize 48x48 $Iconsource $Icondestiny echo "$Name;$Icondestiny;$Exec;" 2>/dev/null 1>>/etc/xlunch/entries.dsv fi

In this sample I used only 48x48, but the nest move is get the size from a config file and auto-resize. This way we could get the svg files from themes and properly use.


Again about creating another repo and new scripts, I made this to create some ready to use tool, instead of hope that users are really able to do their own settings. With this we could deliver a new ready to use xlunch, including the logout and app menu with any effort for them.


About the categories I made some tests getting the Categories to use exactly the way you suggest, I tought the same. I guess the only difference is about use only one entry file but filter inside the script. When its ready I'll show you here.


Tks again for your attention. And one more time I created this repo only to show you the things ok? Best regards!!!

saymoncoppi commented 6 years ago

I made some mistakes with the genscript that I realise now. Ill fix and show later. the original one is able to get the structure, but doenst bring the svg file. easy to fix as I mentioned above. My bad.

Tomas-M commented 6 years ago

Just keep in mind not everyone has 'convert' installed, and not everyone has .gtkrc-2.0 file at all. You should handle cases when any of those are missing.

PMunch commented 6 years ago

Well, the genentries (not genentries-quick) follows the freedesktop specification and looks in all the different paths (in the correct order) and grabs the icon theme from a variety of different desktop environments. It also does the same SVG conversion you are doing and selects the correct size (again according to the specification). So I'm not quite sure what your script is adding over that one. But otherwise I really like what you've done, haven't been able to test out the themes yet but we have an open issue on creating some sample configurations and your work on that is much appreciated. Looking forward to actually trying it :)

saymoncoppi commented 6 years ago

Guys I made new improments using the original one to fix for new themes that uses svg files. fix the theme name (temporary workaround answering Thomas) and start getting the categories.

begin quickgen

ICONTHEME=$(cat ~/.gtkrc-2.0 | grep gtk-icon-theme-name= | sed -e "s/^gtk-icon-theme-name=//" |sed 's/["]//g') if [ $ICONTHEME = "" ]; then echo "Pls type your theme name: " read ICONTHEME fi ICONSIZES="$1 128 64 48 32" # icon search in given order ICONPATHS="/usr/share/icons/$ICONTHEME /usr/share/icons/hicolor /usr/share/pixmaps" NEWICONSIZE=128

$1..$n = dir path with .desktop files

process_directories() { while [ "$1" != "" ]; do

  for desktop in "$1"/*.desktop; do

     Name=
     Icon=
     Exec=
     Hidden=
     Terminal=
     Categories=

     while read LINE; do
        eval $LINE
     done <<< $(cat $desktop | egrep '^(Name|Icon|Exec|Hidden|Terminal|Categories)=' | sed -r "s/ *%.*//" | sed -r "s/=(.*)/='\\1'/")   #'

     if [ "$Hidden" = "true" ]; then
        continue
     fi

     for size in $ICONSIZES; do
        for ICONPATH in $ICONPATHS; do
           icon=$ICONPATH/apps/$size/$Icon
           if [ -f "$icon".svg ]; then Icon="$icon".svg; break; fi
           if [ -f "$icon".png ]; then Icon="$icon".png; break; fi
           if [ -f "$icon" ]; then Icon=$icon; break 2; fi
           icon=$ICONPATH/$size"x"$size/apps/$Icon
           if [ -f "$icon".svg ]; then Icon="$icon".svg; break; fi
           if [ -f "$icon".png ]; then Icon="$icon".png; break; fi
           if [ -f "$icon" ]; then Icon=$icon; break 2; fi
           icon=$ICONPATH/apps/$size"x"$size/$Icon
           if [ -f "$icon".svg ]; then Icon="$icon".svg; break; fi
           if [ -f "$icon".png ]; then Icon="$icon".png; break; fi
           if [ -f "$icon" ]; then Icon=$icon; break 2; fi
           icon=$ICONPATH/$Icon
           if [ -f "$icon".svg ]; then Icon="$icon".svg; break; fi
           if [ -f "$icon".png ]; then Icon="$icon".png; break; fi
           if [ -f "$icon" ]; then Icon=$icon; break 2; fi
        done
     done

     if [ "$Terminal" = "true" ]; then
        Exec="xterm -ls -e $Exec"
     fi

     if [[ $Icon =~ ".png" ]] || [[ $Icon =~ ".xpm" ]]; then
     echo "$Name;$Icon;$Exec;$(echo $Categories | cut -d ";" -f1)"
     else
     Icondestiny="/usr/share/xlunch/icons/entries/"$(basename ${Icon%.*})".png"
     convert -density 1536 -background none -resize $NEWICONSIZE"x"$NEWICONSIZE $Icon $Icondestiny
     echo "$Name;$Icondestiny;$Exec;$(echo $Categories | cut -d ";" -f1)"
     fi

  done

shift done }

process_directories /usr/share/applications 2>/dev/null 1> /etc/xlunch/entries.dsv

end quickgen

if you want some help with samples, pls let me know :)

saymoncoppi commented 6 years ago

Hello guys! I made some updates. Check new screenshots and files. https://github.com/saymoncoppi/xlunchr

I'll change the repo (and scrips) name to something like a xlunch-theme-pack to make this more compliance with the xlunch original one.

Next moves:

Let me know which kind of help you guys need with the orginal xlunch project.

@Tomas-M I fixed the script to get default theme, check it out. By the way this new version get svg files and convert to png to use with the xlib. Additionaly now is possible to choose betwen default or other prefered icon theme pack. I found more small issues related to convertions and the entry names. But I'll fix soon... Let me know if you and @PMunch has suggestions.

See you!

PMunch commented 6 years ago

I still wonder why you won't use the genentries that comes with xlunch. It follows the freedesktop specification for entries and generates the entries file.. The genentriesquick is intended if you don't need the full freedesktop support and want a faster generation. Is your script faster than the genentries one? Otherwise great work, you should post this to r/unixporn, they would probably really enjoy it.

saymoncoppi commented 6 years ago

Sorry for all that time trying to do a new genentries. Its my mistake bc I only realise "today" about the other version of genentries (https://github.com/Tomas-M/xlunch/blob/master/extra/genentries) instead of genentriesquick (https://github.com/Tomas-M/xlunch/blob/master/extra/gentriesquick).

My bad :(

I'll keep trying to do something about categories, translations and themes

PMunch commented 6 years ago

Haha, no problem. I thought it was strange how much work you put into replicating the existing script. It also allows you to only generate one entry for a given desktop file. Works well when used in a hook in the package manager to generate a new entry for the newly installed app.

saymoncoppi commented 6 years ago

In the last question you ask me about the speed, I'll measure this bc i guess my version is faster... Less than 2seconds and the original spent almost 38 sec. We could debug to check which part of your code spend more time than mine.

PMunch commented 6 years ago

I guess what we should actually do is rewrite it in C if we really wanted to speed it up..

fredx181 commented 6 years ago

Here's experiment for .deb package. xlunch_3.2.12 32-bit xlunch_3.2.12 64-bit

Similar as the xlunch build package from the AUR it has a mechanism that "triggers" creating /etc/xlunch/entries.dsv. So if an application installed with apt-get or Synaptic contains a .desktop launcher (in /usr/share/applications) the entries.dsv file will be updated automatically then. In DEBIAN/postinst script there's a line using gentriesquick for that. (can be also the more advanced "genentries", but it's too slow IMHO) Note: Better backup your existing /etc/xlunch/entries.dsv first before installing (it will be overwritten).

Added 3 xlunch script examples which should appear in Menu > System

As said, this is just experimental concept, things can be changed as desired, to unpack, do e.g: dpkg-deb -R xlunch_3.2.12-0_i386.deb xlunch_3.2.12-0_i386

Make your changes and build (inside folder xlunch_3.2.12-0_i386_new):

mkdir xlunch_3.2.12-0_i386_new  
dpkg-deb -b xlunch_3.2.12-0_i386  xlunch_3.2.12-0_i386_new

Not sure, perhaps it would be better to add also 'imagemagick' and 'librsvg2-bin' (has rsvg-convert) as dependencies in the DEBIAN/control file.

EDIT: Fixed mistake in the command to build, directory needs to be created first, so added above mkdir xlunch_3.2.12-0_i386_new

Fred

PMunch commented 6 years ago

If you look at the Arch hook it uses the feature in genentries to only create one entry from one desktop file when you install an application. So you don't have to recreate the entire entries file, making it quite fast.

fredx181 commented 6 years ago

Ah, didn't know, that would be very advanced (I see now the "-f" option of genentries could possibly do that). So you mean it would generate a new entries.dsv by only checking for the last added or removed .desktop file from /usr/share/applications ? You have any idea how to do for Debian ?

PMunch commented 6 years ago

Well, basically running it with -f it returns only one entry which I then add to the entries list and sort out duplicates to remove the old one IIRC. On uninstall it does pretty much the same, but it removes both of any duplicate entries. It's not perfect, but it's good enough considering you can do a full re-create should it mess up. No idea how the debian package manager works, but you can have a look at all the scripts for the Arch installer here(look under the "Sources" tab, that's all the scripts).

fredx181 commented 6 years ago

you can have a look at all the scripts for the Arch installer here(look under the "Sources" tab, that's all the scripts).

Yes, I had seen already, apparently it knows exactly which .desktop file is added or removed from /usr/share/applications when installing or removing a package.

Found a way for Debian now to do the exact thing, it is a bit more complicated script, but works fine from what I tested sofar:

Maybe there's a way less complicated or more robust that I don't know of, basically it works now by comparing the contents of /usr/share/applications before and after installing a package and create entries.dsv accordingly. (it's done in DEBIAN/postinst)

Deb packages new version: EDIT: Oops.. Removed links, found that I made a mistake: When removing a package that was already installed before installing xlunch, it still appears in entries.dsv

fredx181 commented 6 years ago

Here are deb packages version 3.2.12-2 (fixed mistake, see EDIT above) xlunch_3.2.12-2 32-bit xlunch_3.2.12-2 64-bit

The initial install of xlunch takes longer, because the postinst script creates besides /etc/xlunch/entries.dsv also a file /etc/xlunch/inst_entries that keeps track of the entries combined with the corresponding .desktop files inside /usr/share/applications

saymoncoppi commented 6 years ago

Hey Guys what do you think about themes? I'll still working on catergories until its not a native feature... but themes are ready to use.

PMunch commented 6 years ago

I haven't had the time to play around with them. But from the screenshots they look great! Definitely something we should incorporate into the installs. I'm thinking about creating a setup and configuration utility that will allow you to change themes, regenerate entries, etc.

PMunch commented 6 years ago

@fredx181 I created this little script that could be chained with xlunch in order to update the entries-file. It should run really fast when there aren't any entries that needs to update, but will obviously take a bit longer if you have updated any entries. Could be practical for package managers without hooks.

fredx181 commented 5 years ago

@PMunch , finally tried your updateentries script, but it doesn't work for me. Not really sure, but I think it is because any new added .desktop file to /usr/share/applications often doesn't have newer timestamp than the others.

PMunch commented 5 years ago

Hmm, that sounds like an issue with the installation. Maybe there is another time stamp that could be used? You can have a look at the different stamps available and see if you find one that changes as you would expect.

fredx181 commented 5 years ago

@PMunch Got it working now. Changing the find command (line 45) to:
done <<< $(find -L "$appfolder" -name "*.desktop" -printf "%C@ %p\n" 2>/dev/null | sort -nr) made it work fine to update entries.dsv when new application(s) installed , thanks for the script ! (changed -printf "%T@ %p\n" to -printf "%C@ %p\n") And: In the xlunch postinst script (in DEBIAN folder):

if [ -f /etc/xlunch/entries.dsv ]; then
updateentries /etc/xlunch/entries.dsv
  if [ "$1" = "triggered" ]; then
    exit 0
  fi
fi

Also in DEBIAN folder, a file named "triggers", with content: interest /usr/share/applications EDIT: Mmmm.. not perfect though, when removing an application it doesn't update entries.dsv

GlowingScrewdriver commented 1 year ago

Why not just run genentries every time /usr/share/applications is triggered? I understand it might be a couple of seconds slower, but it's better than nothing; especially since it's not very often that a user might want to perform these operations (uninstallations and upgradations of apps etc.).

At least it would be a starting point for the DEB package.

Also, perhaps we could get genentries to write to /etc/xlunch/entries.dsv? Since dpkg is run as root (and that too sometimes with, sometimes without sudo), trying to determine the user's home directory can just get messy and inconsistent.