Skip to content

Add display-modes extension#8553

Merged
raycastbot merged 6 commits intoraycast:mainfrom
codifilo:ext/display-modes
Oct 16, 2023
Merged

Add display-modes extension#8553
raycastbot merged 6 commits intoraycast:mainfrom
codifilo:ext/display-modes

Conversation

@codifilo
Copy link
Contributor

@codifilo codifilo commented Sep 24, 2023

Description

A extension that lists your plugged displays and for each one it lists the available modes (resolution, scale and refresh rate) and allows to switch to a new display mode.

Screencast

screencast.mov

Checklist

- add screenshots
- build swift
- add shortcuts
- use proper linter
- tweaks
- improve selected mode icon
- improve swift code
- show retina modes first
- first working version
- improve detail
- show display modes
- format display info
- parse swift output
- initial commit
@raycastbot raycastbot added the new extension Label for PRs with new extensions label Sep 24, 2023
@raycastbot
Copy link
Collaborator

Congratulation on your new Raycast extension! 🚀

We will review it shortly. Once the PR is approved and merged, the extension will be available on the Store.

Copy link
Collaborator

@pernielsentikaer pernielsentikaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi 👋

Thanks for your contribution 💪

I have now tested your extension, and I have some feedback ready for you:

Suggestions (For later)

  • Add a menubar command too 🙂
  • Allow favorite modes in the list (if possible)

I'm looking forward to testing this extension again 🔥

Request a new review when you are ready. Feel free to contact me here or at Slack if you have any questions.

@@ -0,0 +1,115 @@
import { ActionPanel, List, Action, useNavigation, showHUD, KeyEquivalent } from "@raycast/api";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { ActionPanel, List, Action, useNavigation, showHUD, KeyEquivalent } from "@raycast/api";
import { ActionPanel, List, Action, useNavigation, showHUD, Icon } from "@raycast/api";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

actions={
<ActionPanel>
<Action
title="Change Display Mode"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title="Change Display Mode"
title="Change Display Mode"
icon={Icon.Monitor}

Adding an icon makes it even more beautiful 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Looks better!

actions={
<ActionPanel>
<Action.Push
title="Show Display Modes"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
title="Show Display Modes"
title="Show Display Modes"
icon={Icon.Monitor}

Adding an icon makes it even more beautiful 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Looks better!

<Action.Push
title="Show Display Modes"
target={detail(display)}
{...(key ? { modifiers: ["opt"], key: key } : {})}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{...(key ? { modifiers: ["opt"], key: key } : {})}
{...(key ? { shortcut: { modifiers: ["opt"], key: key } } : {})}

You missed shortcut here, it should look like the above suggestion

If you hold for 400 ms you'll get the same behavior out of the box, I would actually just remove the above and rely on ⌘+num instead which is how Raycast works in every list 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah this is totally unnecessary then. I removed it.
Very convenient default behaviour from Raycast 👏

<ActionPanel>
<Action
title="Change Display Mode"
{...(key ? { modifiers: ["opt"], key: key } : {})}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{...(key ? { modifiers: ["opt"], key: key } : {})}
{...(key ? { shortcut: { modifiers: ["opt"], key: key } } : {})}

You missed shortcut here, it should look like the above suggestion

If you hold for 400 ms you'll get the same behavior out of the box, I would actually just remove the above and rely on ⌘+num instead which is how Raycast works in every list 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah this is totally unnecessary then. I removed it.
Very convenient default behaviour from Raycast 👏

Comment on lines +1 to +8
import { environment, getPreferenceValues, Icon, Image, Keyboard, List } from "@raycast/api";
import { execa, ExecaError } from "execa";
import { chmod } from "fs/promises";
import { join } from "path";
import { DisplayInfo, Mode } from "./types";

const preferences: Preferences = getPreferenceValues();

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { environment, getPreferenceValues, Icon, Image, Keyboard, List } from "@raycast/api";
import { execa, ExecaError } from "execa";
import { chmod } from "fs/promises";
import { join } from "path";
import { DisplayInfo, Mode } from "./types";
const preferences: Preferences = getPreferenceValues();
import { environment } from "@raycast/api";
import { execa } from "execa";
import { chmod } from "fs/promises";
import { join } from "path";
import { DisplayInfo, Mode } from "./types";

Just removed unused imports

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +53 to +76
export function numberToKey(n: number): Keyboard.KeyEquivalent | undefined {
switch (n) {
case 1:
return "1";
case 2:
return "2";
case 3:
return "3";
case 4:
return "4";
case 5:
return "5";
case 6:
return "6";
case 7:
return "7";
case 8:
return "8";
case 9:
return "9";
default:
return undefined;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function numberToKey(n: number): Keyboard.KeyEquivalent | undefined {
switch (n) {
case 1:
return "1";
case 2:
return "2";
case 3:
return "3";
case 4:
return "4";
case 5:
return "5";
case 6:
return "6";
case 7:
return "7";
case 8:
return "8";
case 9:
return "9";
default:
return undefined;
}
}

If relying on default Raycast behavior this is not necessary 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

@pernielsentikaer pernielsentikaer self-assigned this Oct 4, 2023
@codifilo
Copy link
Contributor Author

codifilo commented Oct 4, 2023

@pernielsentikaer Thank you very much for your feedback.
I added the suggested changes to the PR.

Copy link
Collaborator

@pernielsentikaer pernielsentikaer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi 👋

Looks good to me, approved 🔥

@raycastbot raycastbot merged commit f75f797 into raycast:main Oct 16, 2023
@raycastbot
Copy link
Collaborator

Published to the Raycast Store:
https://raycast.com/agustin.prats/display-modes

@raycastbot
Copy link
Collaborator

🎉 🎉 🎉

Such a great contribution deserves a reward, but unfortunately we couldn't find your Raycast account based on your GitHub username.
Please link your GitHub account to your Raycast account to receive your credits and soon be able to exchange them for some swag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new extension Label for PRs with new extensions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants