Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Opening links from specific Slack workspace #436

GregEisenberg started this conversation in General
Discussion options

Hey all
I have been keeping work and life separated while doing both on the same mac machine by using Google for Work and MS Office for life. (I won't bore you with the reasons why)

Finicky has a been a huge help to achieve this but I am still struggling to get some things correct . The main thing I am trying to figure out is how to have links from the Slack (the app) from a specific workspace use a specific browser. Is this even possible?
Each workspace has its own name and URL but I am not sure what value to check. Beyond that it seems that what I have tried fails because its getting undefined for a source object

Note any XXX is just removed to not leak info

 // Links from Slack in my XXX workspace -> Chrome
 {
 match: ({ source }) => {
 console.log("* * * * source: " + source);
 if (!source) return false; 
 
 console.log("* * * * source.bundleId: " + source.bundleId + " source.url: " + source.url);
 source.bundleId === "com.tinyspeck.slackmacgap" && source.url.includes("XXX.slack.com")
 },
 browser: "Google Chrome:greg@XXXX"

but this not working and one reason it is not working is that source is undefined. Here is Finicky's debug

VM refresh complete
duration: 88.29ms
6:05:45 PM URL received
 url: https://some-place.com
6:05:45 PM Setting opener
 name: Slack
 bundleId: com.tinyspeck.slackmacgap
 path: /Applications/Slack.app
6:05:45 PM. * * * * source: undefined
6:05:45 PM Final browser options 
 name: Microsoft Edge
 openInBackground: null
 profile: 
 args: 
 appType: appName

I think Finicky v3 there was an "opener" object but I can not use opener because Finicky 4 tells me that is deprecated now

Any and all help greatly appreciated

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

Note after more debugging I moved back to using opener despite the deprecation warning. However I can not seem to limit it to just some workspaces :-(

{
 match: ( {opener} ) => {
 //console.log("* * * * opener: ", opener);
 if (!opener) return false; 
 
 //console.log("* * * * opener.bundleId: ", opener.bundleId);
 if (opener.bundleId === "com.tinyspeck.slackmacgap") {
 return true;
 }
 return false;
 },
 browser: "Google Chrome:greg@XXXX.io"
 }
You must be logged in to vote
1 reply
Comment options

Look into /Applications/Finicky.app/Contents/Resources/finicky.d.ts, you should see the definition for the urlMatcher. This is coming from https://github.com/johnste/finicky/blob/main/packages/config-api/src/configSchema.ts.

For ref this is what I have currently:

/** This file is generated by the generate-typedefs.ts script. Do not edit it directly. */
interface FinickyUtils {
 matchHostnames: (hostnames: Array<string | RegExp> | string | RegExp) => (url: URL) => boolean;
 getModifierKeys: () => {
 shift: boolean;
 option: boolean;
 command: boolean;
 control: boolean;
 capsLock: boolean;
 fn: boolean;
 };
 getSystemInfo: () => {
 localizedName: string;
 name: string;
 };
 getPowerInfo: () => {
 isCharging: boolean;
 isConnected: boolean;
 percentage: number | null;
 };
 isAppRunning: (identifier: string) => boolean;
}
declare global {
 const finicky: FinickyUtils
}
export type ProcessInfo = {
 name: string;
 bundleId: string;
 path: string;
};
export { ProcessInfo };
type OpenUrlOptions = {
 opener: ProcessInfo | null;
};
export { OpenUrlOptions };
type BrowserResolver = (args_0: URL, args_1: OpenUrlOptions) => string | {
 name: string;
 appType?: ("appName" | "bundleId" | "path" | "none") | undefined;
 openInBackground?: boolean | undefined;
 profile?: string | undefined;
 args?: string[] | undefined;
};
export { BrowserResolver };
type ConfigOptions = {
 urlShorteners?: string[] | undefined;
 /** Log to file on disk */
 logRequests?: boolean | undefined;
 /** Check for updates */
 checkForUpdates?: boolean | undefined;
};
export { ConfigOptions };
type UrlMatcherFunction = (args_0: URL, args_1: OpenUrlOptions) => boolean;
export { UrlMatcherFunction };
type UrlMatcher = string | RegExp | UrlMatcherFunction;
export { UrlMatcher };
type UrlTransformer = (args_0: URL, args_1: OpenUrlOptions) => string | URL;
export { UrlTransformer };
type UrlTransformSpecification = string | URL | UrlTransformer;
export { UrlTransformSpecification };
type UrlRewriteRule = {
 match: UrlMatcher | UrlMatcher[];
 url: UrlTransformSpecification;
};
export { UrlRewriteRule };
type BrowserSpecification = null | string | {
 name: string;
 appType?: ("appName" | "bundleId" | "path" | "none") | undefined;
 openInBackground?: boolean | undefined;
 profile?: string | undefined;
 args?: string[] | undefined;
} | BrowserResolver;
export { BrowserSpecification };
type BrowserHandler = {
 match: UrlMatcher | UrlMatcher[];
 browser: BrowserSpecification;
};
export { BrowserHandler };
/**
 This represents the full `~/.finicky.js` configuration object

 Example usage:

 \```js
 export default = {
 defaultBrowser: "Google Chrome",
 options: {
 logRequests: false
 },
 handlers: [{
 match: "example.com*",
 browser: "Firefox"
 }]
 }
 \```
 */
type FinickyConfig = {
 /** The default browser or app to open for urls where no other handler */
 defaultBrowser: null | string | {
 name: string;
 appType?: ("appName" | "bundleId" | "path" | "none") | undefined;
 openInBackground?: boolean | undefined;
 profile?: string | undefined;
 args?: string[] | undefined;
 } | BrowserResolver;
 options?: ConfigOptions | undefined;
 /** An array of rewriter rules that can change the url being opened */
 rewrite?: UrlRewriteRule[] | undefined;
 /** An array of handlers to select which browser or app to open for urls */
 handlers?: BrowserHandler[] | undefined;
};
export { FinickyConfig };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /