sonnyp / Junction

Application/browser chooser
https://flathub.org/apps/re.sonny.Junction
GNU General Public License v3.0
458 stars 29 forks source link

Select the most frequently used app by default #29

Open rohmishra opened 2 years ago

rohmishra commented 2 years ago

This is potentially related to #12 and i suggested this idea in the thread over there.

In my experience people usually have one default app that they might wanna use regularly but have different apps installed that they might wanna choose for one time use.

For example:

A nice quality of life improvement in this case would be to automatically select the most frequent (or previously selected) application for that particular type such that instead of having to select the app after hitting enter, you could hit enter twice to open a image in viewer without having to set eog as default.

If you want to use a different app, you can certainly just tap/click the app instead as you do now.

This screenshot might help with how the default view when Junction opens might look. The highlight could potentially be toned down or be a outline instead. as white text on off-white background is a bit harder to read. The highlight the dash uses seems to be visible enough while not being too bright.

image image

Here is how this might work:

sonnyp commented 2 years ago

Regardless of what we decide to do with order or layout - I think this is desirable.

I would start this way

  1. Keep a counter of app use per resource type
  2. Always select the app for which the counter is the greatest

Everything else is probably unnecessary for now and might conflict.

Would you like to give it a go?

We can store the counters in gsettings

https://wiki.gnome.org/HowDoI/GSettings https://docs.gtk.org/gio/class.Settings.html

https://github.com/sonnyp/Junction/blob/main/data/re.sonny.Junction.gschema.xml https://github.com/sonnyp/Junction/blob/main/src/common.js

rohmishra commented 2 years ago

Ill give it a try, lets see what can be done and what would be the best way to do it. Also P.S. it looks like the Makefile never compiles the schemas.

sonnyp commented 2 years ago

@rohmishra the dev entry point does - https://github.com/sonnyp/Junction/blob/main/re.sonny.Junction#L15

rohmishra commented 2 years ago

hmm... I got this with make dev; make run-host so i just ran glib-compile-schemas manually which fixed the issue. I havent changed anything yet cause I am/was busy with something else so I told myself ill take a look at it when i get to it.

GSETTINGS_SCHEMA_DIR=./data ./install/bin/re.sonny.Junction

(gjs:38876): Gjs-CRITICAL **: 15:23:15.447: JS ERROR: Error: GSettings schema re.sonny.Junction not found
_init@resource:///org/gnome/gjs/modules/core/overrides/Gio.js:551:23
@file:///home/rmishra/Projects/Junction/install/share/re.sonny.Junction/common.js:3:25

And now it works without having to install them. IDK what went wrong there but yes it works now 😞

sonnyp commented 2 years ago

You have 2 options

https://github.com/sonnyp/Junction#development

or just build in GNOME Builder

jgabriel98 commented 2 years ago

I would start this way

  1. Keep a counter of app use per resource type
  2. Always select the app for which the counter is the greatest

about using a simple counter, i think there's a big problem:

my suggestion is to use some math+weights trick to make more recent selection more meaningfull:


// controls the weight of most recent picks.
const lambda = 0.25;

function whenAppIsChoosen(pickedApp) {
  maxScore = priorityScore.get(previousAppWithHighestScore);
  thisPickWeight = (maxScore * lambda);
  previousScoreWeight = priorityScore.get(pickedApp) * (1 - lambda);
  priorityScore.set(pickedApp, previousScoreWeight + thisPickWeight +1);
}

there's only one thing that concers me: float/double overflow. so we have one workarround: instead of making the recent picks grow more, we can make all previous picks shrink, like that:


// controls the weight of most recent picks.
const lambda = 0.25;

function whenAppIsChoosen(pickedApp) {
  maxScore = priorityScore.get(previousAppWithHighestScore);
  thisPickWeight = maxScore * lambda;
  previousScoreWeight = priorityScore.get(pickedApp) * (1 - lambda);
  thisAppNewScore = previousScoreWeight + thisPickWeight +1;
  priorityScore.set(pickedApp, thisAppNewScore);

  /* maxScore is always 1, unless thisAppNewScore is the new maxScore
  so we only shrink stuff when maxScore is not 1  */
  if (maxScore < thisAppNewScore) {
    maxScore = thisAppNewScore;

    // time to shrink  
    for(i=0; i<priorityScore.length; i++) {
      priorityScore[i] = priorityScore/maxScore;
    }
  }
}
sonnyp commented 2 years ago

Thanks, as I said, the counter only approach is just to get started. We are aware it won't be enough.

Before we decide on an algorithm, we need to use the feature and gather feedback.

For example, someone posted a review of Junction in which they praise the fact that selecting an app always pushes it to the list of options https://www.youtube.com/watch?v=rfVd9bhRWxs

jgabriel98 commented 2 years ago

No problem! didn't mean to criticize nor anything like that. Just posted some ideas i had (in case it becomes handy).

note: i've found out about Junction from this video you mentioned hahaha