johnste / finicky

A macOS app for customizing which browser to start

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Time based rules

wildeyes opened this issue · comments

Is your feature request related to a problem? Please describe.
I want to make a rule that is relevant only for work - that is, time / wifi based. It would annoy me greatly to have that rule on the weekend.

Describe the solution you'd like
A parameter that'll look as following:

{
  timeBased: {
    startTime: string;
    endTime: string;
  }

Describe alternatives you've considered

  1. Switching finicky config files based on cronjob.

You can check the date in the current version of Finicky. E.g.

   {
      // Open Safari if it's Sunday or Monday
      match: () => {
        const day = (new Date()).getDay();
        return (day === 0 || day === 6);
      },
      browser: "Safari"
    },

Check out the Date object documentation if you need more info. There is no way right now to check which wifi you are on or similar, I hope the time based solution will work for you.

Let me know if you have issues getting this to work.

🤦 🤦 🤦
I forgot that this is finicky and not some configuration-based script. We're running JS in real-time, of course! everything I mentioned is possible without a dedicated API.

Let's close this as out of scope and I'll update with an example (And maybe will even PR it if you find it good :)

commented

I didn't see an example so here is what I'm using

  handlers: [
    // if outside of working hours, use Safari Tech Preview
    {
      match: () => {
        const date = new Date();
        const day = date.getDay();
        const hour = date.getHours();
        return day === 6 || day === 7 || hour >= 18 || hour <= 7;
      },
      browser: "Safari Technology Preview",
    }
  ]