Junction icon indicating copy to clipboard operation
Junction copied to clipboard

Select the most frequently used app by default

Open rohmishra opened this issue 3 years ago • 8 comments

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:

  • You always use firefox for links but you might wanna choose edge once for a teams link or chrome because the source has mentioned it only works with chrome.
  • You always use document reader for most of your PDF files but might wanna open it in libreoffice or xpdf to do some intensive edits.
  • You always use image viewer (eog, or any other viewer) for images but might wanna open a image in GIMP to edit it

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:

  • For filetypes for which we dont have a history/freq available, do not select any app.
  • Once the user selects the app once, we select that by default the next time
  • Once a app is used for that type more than x times (maybe 10?), we now know the user's preference is to use that app (eg. eog for png) for that file type.
  • Next time user opens a png, select Image viewer as default selection.
  • Only keep preference for last 14 days or last 20 uses for that filetype, whichever is higher. IF the user starts using a different app, the count for say gthumb will be higher than eog, so we select that by default.

rohmishra avatar Nov 20 '21 16:11 rohmishra

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

sonnyp avatar Dec 05 '21 19:12 sonnyp

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.

rohmishra avatar Dec 05 '21 20:12 rohmishra

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

sonnyp avatar Dec 05 '21 21:12 sonnyp

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 😞

rohmishra avatar Dec 05 '21 21:12 rohmishra

You have 2 options

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

or just build in GNOME Builder

sonnyp avatar Dec 05 '21 21:12 sonnyp

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:

  • let's say you use app A to open .mp4 files, for about 5 months, so the counter is something like +200
  • now you installed a new app B to open .mp4 files, and guess what? you love it and now prefer it over app A!
  • but now you have to open .mp4 file +200 times, to make it the new default pre-selected app

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;
    }
  }
}

jgabriel98 avatar Jan 02 '22 04:01 jgabriel98

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

sonnyp avatar Jan 02 '22 12:01 sonnyp

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

jgabriel98 avatar Jan 02 '22 13:01 jgabriel98