Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toggle-fn extension #13942

Merged
merged 5 commits into from
Aug 25, 2024
Merged

Add toggle-fn extension #13942

merged 5 commits into from
Aug 25, 2024

Conversation

elonwoo
Copy link
Contributor

@elonwoo elonwoo commented Aug 9, 2024

Description

Toggle the "Use all F1, F2, etc. keys as standard function keys" option in macOS System Preferences.

Screencast

Toggle-Fn

Checklist

@raycastbot
Copy link
Collaborator

Congratulations on your new Raycast extension! 🚀

You can expect an initial review within five business days.

Once the PR is approved and merged, the extension will be available on our Store.

@raycastbot raycastbot added the new extension Label for PRs with new extensions label Aug 9, 2024
@pernielsentikaer
Copy link
Collaborator

Thanks for your contribution 👋

It works as expected as long as you don't change the language. I tried to switch to my native language, Danish, and it stops working there

Raycast16082024-bWT0Rdhs png@2x

Can you come up with a way that works for other languages too?

@pernielsentikaer pernielsentikaer self-assigned this Aug 16, 2024
@elonwoo
Copy link
Contributor Author

elonwoo commented Aug 19, 2024

Thanks for your contribution 👋

It works as expected as long as you don't change the language. I tried to switch to my native language, Danish, and it stops working there

Raycast16082024-bWT0Rdhs png@2x

Can you come up with a way that works for other languages too?

Sorry, I know what the problem is, but it is difficult for me to adapt this script to so many languages ​​without the corresponding API provided by Mac.

I am not able to solve this problem at the moment, and I hope that there will be contributors in the community to improve this extension.

@pernielsentikaer

@pernielsentikaer
Copy link
Collaborator

Maybe we can tweak it, this seems to work with other language, but it doesn't close the window, maybe you can fix that? It toggles in checkbox at least 🙂

set osver to system version of (system info)
if osver  13.0 then
	open location "x-apple.systempreferences:com.apple.Keyboard-Settings.extension"
	delay 1 -- Wait for the settings to open
	
	if osver  14.0 then
		tell application "System Settings"
			reveal anchor "FunctionKeys" of pane id "com.apple.Keyboard-Settings.extension"
		end tell
	else
		tell application "System Events" to tell process "System Settings"
			repeat until window begins with "Keyboard" exists
				delay 0.5
			end repeat
			
			repeat until exists of (1st window whose value of attribute "AXMain" is true)
				delay 0.5
			end repeat
			
			repeat until exists group 1 of group 2 of splitter group 1 of group 1 of window 1
				delay 0.5
			end repeat
			
			set keyboardButton to 3
			try
				click button keyboardButton of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
			on error errorMessage number errorNumber
				if errorNumber is -1719 then
					set keyboardButton to 1
					click button keyboardButton of group 2 of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1
				end if
			end try
			
			repeat until sheet 1 of window 1 exists
				delay 0.5
			end repeat
			
			keystroke "f"
		end tell
	end if
	
	tell application "System Events" to tell process "System Settings"
		repeat until exists (checkbox 1 of group 1 of scroll area 1 of group 2 of splitter group 1 of group 1 of sheet 1 of window 1)
			delay 0.5
		end repeat
		
		click checkbox 1 of group 1 of scroll area 1 of group 2 of splitter group 1 of group 1 of sheet 1 of window 1
		
		repeat
			try
				repeat while sheet 1 of window 1 exists
					delay 0.5
				end repeat
				exit repeat
			end try
		end repeat
	end tell
	
	tell application "System Settings" to quit
else if osver < 13.0 then
	tell application "System Settings"
		set current pane to pane "com.apple.preference.keyboard"
	end tell
	
	tell application "System Events"
		if UI elements enabled then
			tell application process "System Preferences"
				repeat until exists tab group 1 of window "Keyboard"
					delay 0.5
				end repeat
				click radio button 1 of tab group 1 of window "Keyboard"
				try
					click checkbox 1 of tab group 1 of window "Keyboard"
				end try
				try
					click checkbox 2 of tab group 1 of window "Keyboard"
				end try
			end tell
			tell application "System Settings" to quit
		else
			tell application "System Settings"
				activate
				set current pane to pane "com.apple.preference.security"
				display dialog "UI element scripting is not enabled. Please activate this app under Privacy -> Accessibility so it can access the settings it needs."
			end tell
		end if
	end tell
end if

@elonwoo
Copy link
Contributor Author

elonwoo commented Aug 24, 2024

@pernielsentikaer

I fixed it based on your code, thank you.

My macOS version is 14.3.1.

I tested in these languages and works well.

  • English
  • Mandarin Chinese
  • Danish
  • Spanish
  • Hindi
  • Arabic
  • French
  • Portuguese
  • Japanese
  • Korean

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.

Seems to work 🔥

The icon is hard to see in dark mode, can you provide alternative dark mode image or make another one?

@elonwoo
Copy link
Contributor Author

elonwoo commented Aug 25, 2024

@pernielsentikaer added a dark icon. Thank you for taking the time to check.

image

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 0a508d9 into raycast:main Aug 25, 2024
2 checks passed
Copy link
Contributor

Published to the Raycast Store:
https://raycast.com/elonwoo/toggle-fn

@raycastbot
Copy link
Collaborator

🎉 🎉 🎉

We've rewarded your Raycast account with some credits. You will soon be able to exchange them for some swag.

astrit added a commit to astrit/extensions that referenced this pull request Aug 26, 2024
- raycast#14189 - Fix date starting monday and update default colors
- fix cache calue when no services present (raycast#14192)
- Update scrapbook extension (raycast#14080)
- Update CODEOWNERs
- Update iconpark extension (raycast#14064)
- Update CODEOWNERs
- Update CODEOWNERs
- Update chatgpt extension (raycast#14178)
- Update svgl extension (raycast#14149)
- Update cron extension (raycast#14086)
- [Easydict v2.9.2] 💎 feat: support http API endpoint for OpenAI (raycast#14179)
- Update arc extension (raycast#14185)
- Fix error when reading name from undefined (raycast#14135)
- Update custom-folder extension (raycast#14184)
- Update CODEOWNERs
- [beeminder] Fix data synchronization after a datapoint submission (raycast#14158)
- feat(spotify-player): preference to show only music (raycast#14160)
- Update CODEOWNERs
- Reclaim - Make Smart Habit actions respect override setting / fail API errors silently / only strip planner emojis (raycast#14094)
- Add my new Raycast extension: Dropstab Crypto Toolbox (raycast#14047)
- Update work-time-countdown extension (raycast#14142)
- Update CODEOWNERs
- Add oxford-collocation-dictionary extension (raycast#13959)
- Update \`cPanel\` extension (view dbs + limited add dns record + move url check out of hook) (raycast#14138)
- Update LaunchAgents extension (raycast#14157)
- Update CODEOWNERs
- Add toggle-fn extension (raycast#13942)
- Update remember-the-date extension (raycast#14151)
- [Wikipedia] Add languages (raycast#14167)
- Update CODEOWNERs
- Add thingiverse extension (raycast#13967)
- don\'t show detail if list is empty (raycast#14137)
- Update fantastical extension (raycast#14054)
- Update CODEOWNERs
- Initial commit for @ Profile extension. (raycast#14002)
- Update CODEOWNERs
- Fix LaunchAgents folder creation for inexistent folder (raycast#14053)
- Add Luna Search extension (raycast#14006)
- Update CODEOWNERs
- chore (grafana): use service token instead of api keys (raycast#14087)
- Add \`Remove All Searches\` action for \`spotify-player\` Search command (raycast#14084)
- Update CODEOWNERs
- Added support to select either the NBA or the WNBA - default remains NBA (raycast#13970)
- Update CODEOWNERs
- Update google-search extension (raycast#13887)
- [beeminder] Several updates to the Beeminder extension (raycast#13976)
- Add Bonjour extension (raycast#14046)
- Update claude extension (raycast#14121)
- Update pdf-tools extension (raycast#14118)
- Update cobalt extension (raycast#14052)
- Update CODEOWNERs
- [TablePlus] close raycast#4231 + add dropdown filter (raycast#14116)
- Update app-icon-generator extension (raycast#13847)
- Update CODEOWNERs
- [Everhour] fix raycast#13548 + modernize + add metadata/images,README (raycast#13999)
- Update CODEOWNERs
- [Migadu] cache most results + minor api refactor (raycast#13990)
- Initial version of Threads extension. (raycast#13989)
- Update viacep extension (raycast#14108)
- Deleting my extension ig (raycast#14029)
- [toggl-track] Remove seconds from menubar timer (raycast#13964)
- Update CODEOWNERs
- Add octoprint extension (raycast#13975)
- Update hud.md
- Update CODEOWNERs
- Update text-shortcuts extension (raycast#14033)
- Update vade-mecum extension (raycast#14104)
- Docs: Update the utils docs
- Update CODEOWNERs
- [Notion] Add LaunchContext support for Quick Capture (raycast#13953)
- Update CODEOWNERs
- [Tailwind CSS] Add \`size\` utility classes (raycast#14102)
- [GitHub] Brought back fast browsing to cloned repos. (raycast#13992)
- Update CODEOWNERs
- Add git-buddy extension (raycast#13116)
- Update CODEOWNERs
- [Raycast Notification] Added success and failure notification types (raycast#13958)
- Update CODEOWNERs
- [Linkwarden] fix raycast#13613 (API uses Bearer Auth) (raycast#14070)
- Update olympic-games extension (raycast#14090)
- Update CODEOWNERs
- Update folder search extension (raycast#14077)
- Fix weekdays and change display method
raycastbot pushed a commit that referenced this pull request Aug 27, 2024
* Update cron extension

- #14189 - Fix date starting monday and update default colors
- fix cache calue when no services present (#14192)
- Update scrapbook extension (#14080)
- Update CODEOWNERs
- Update iconpark extension (#14064)
- Update CODEOWNERs
- Update CODEOWNERs
- Update chatgpt extension (#14178)
- Update svgl extension (#14149)
- Update cron extension (#14086)
- [Easydict v2.9.2] 💎 feat: support http API endpoint for OpenAI (#14179)
- Update arc extension (#14185)
- Fix error when reading name from undefined (#14135)
- Update custom-folder extension (#14184)
- Update CODEOWNERs
- [beeminder] Fix data synchronization after a datapoint submission (#14158)
- feat(spotify-player): preference to show only music (#14160)
- Update CODEOWNERs
- Reclaim - Make Smart Habit actions respect override setting / fail API errors silently / only strip planner emojis (#14094)
- Add my new Raycast extension: Dropstab Crypto Toolbox (#14047)
- Update work-time-countdown extension (#14142)
- Update CODEOWNERs
- Add oxford-collocation-dictionary extension (#13959)
- Update \`cPanel\` extension (view dbs + limited add dns record + move url check out of hook) (#14138)
- Update LaunchAgents extension (#14157)
- Update CODEOWNERs
- Add toggle-fn extension (#13942)
- Update remember-the-date extension (#14151)
- [Wikipedia] Add languages (#14167)
- Update CODEOWNERs
- Add thingiverse extension (#13967)
- don\'t show detail if list is empty (#14137)
- Update fantastical extension (#14054)
- Update CODEOWNERs
- Initial commit for @ Profile extension. (#14002)
- Update CODEOWNERs
- Fix LaunchAgents folder creation for inexistent folder (#14053)
- Add Luna Search extension (#14006)
- Update CODEOWNERs
- chore (grafana): use service token instead of api keys (#14087)
- Add \`Remove All Searches\` action for \`spotify-player\` Search command (#14084)
- Update CODEOWNERs
- Added support to select either the NBA or the WNBA - default remains NBA (#13970)
- Update CODEOWNERs
- Update google-search extension (#13887)
- [beeminder] Several updates to the Beeminder extension (#13976)
- Add Bonjour extension (#14046)
- Update claude extension (#14121)
- Update pdf-tools extension (#14118)
- Update cobalt extension (#14052)
- Update CODEOWNERs
- [TablePlus] close #4231 + add dropdown filter (#14116)
- Update app-icon-generator extension (#13847)
- Update CODEOWNERs
- [Everhour] fix #13548 + modernize + add metadata/images,README (#13999)
- Update CODEOWNERs
- [Migadu] cache most results + minor api refactor (#13990)
- Initial version of Threads extension. (#13989)
- Update viacep extension (#14108)
- Deleting my extension ig (#14029)
- [toggl-track] Remove seconds from menubar timer (#13964)
- Update CODEOWNERs
- Add octoprint extension (#13975)
- Update hud.md
- Update CODEOWNERs
- Update text-shortcuts extension (#14033)
- Update vade-mecum extension (#14104)
- Docs: Update the utils docs
- Update CODEOWNERs
- [Notion] Add LaunchContext support for Quick Capture (#13953)
- Update CODEOWNERs
- [Tailwind CSS] Add \`size\` utility classes (#14102)
- [GitHub] Brought back fast browsing to cloned repos. (#13992)
- Update CODEOWNERs
- Add git-buddy extension (#13116)
- Update CODEOWNERs
- [Raycast Notification] Added success and failure notification types (#13958)
- Update CODEOWNERs
- [Linkwarden] fix #13613 (API uses Bearer Auth) (#14070)
- Update olympic-games extension (#14090)
- Update CODEOWNERs
- Update folder search extension (#14077)
- Fix weekdays and change display method

* Update changelog
raycastbot pushed a commit that referenced this pull request Aug 29, 2024
* Update cron extension

- #14189 - Fix date starting monday and update default colors
- fix cache calue when no services present (#14192)
- Update scrapbook extension (#14080)
- Update CODEOWNERs
- Update iconpark extension (#14064)
- Update CODEOWNERs
- Update CODEOWNERs
- Update chatgpt extension (#14178)
- Update svgl extension (#14149)
- Update cron extension (#14086)
- [Easydict v2.9.2] 💎 feat: support http API endpoint for OpenAI (#14179)
- Update arc extension (#14185)
- Fix error when reading name from undefined (#14135)
- Update custom-folder extension (#14184)
- Update CODEOWNERs
- [beeminder] Fix data synchronization after a datapoint submission (#14158)
- feat(spotify-player): preference to show only music (#14160)
- Update CODEOWNERs
- Reclaim - Make Smart Habit actions respect override setting / fail API errors silently / only strip planner emojis (#14094)
- Add my new Raycast extension: Dropstab Crypto Toolbox (#14047)
- Update work-time-countdown extension (#14142)
- Update CODEOWNERs
- Add oxford-collocation-dictionary extension (#13959)
- Update \`cPanel\` extension (view dbs + limited add dns record + move url check out of hook) (#14138)
- Update LaunchAgents extension (#14157)
- Update CODEOWNERs
- Add toggle-fn extension (#13942)
- Update remember-the-date extension (#14151)
- [Wikipedia] Add languages (#14167)
- Update CODEOWNERs
- Add thingiverse extension (#13967)
- don\'t show detail if list is empty (#14137)
- Update fantastical extension (#14054)
- Update CODEOWNERs
- Initial commit for @ Profile extension. (#14002)
- Update CODEOWNERs
- Fix LaunchAgents folder creation for inexistent folder (#14053)
- Add Luna Search extension (#14006)
- Update CODEOWNERs
- chore (grafana): use service token instead of api keys (#14087)
- Add \`Remove All Searches\` action for \`spotify-player\` Search command (#14084)
- Update CODEOWNERs
- Added support to select either the NBA or the WNBA - default remains NBA (#13970)
- Update CODEOWNERs
- Update google-search extension (#13887)
- [beeminder] Several updates to the Beeminder extension (#13976)
- Add Bonjour extension (#14046)
- Update claude extension (#14121)
- Update pdf-tools extension (#14118)
- Update cobalt extension (#14052)
- Update CODEOWNERs
- [TablePlus] close #4231 + add dropdown filter (#14116)
- Update app-icon-generator extension (#13847)
- Update CODEOWNERs
- [Everhour] fix #13548 + modernize + add metadata/images,README (#13999)
- Update CODEOWNERs
- [Migadu] cache most results + minor api refactor (#13990)
- Initial version of Threads extension. (#13989)
- Update viacep extension (#14108)
- Deleting my extension ig (#14029)
- [toggl-track] Remove seconds from menubar timer (#13964)
- Update CODEOWNERs
- Add octoprint extension (#13975)
- Update hud.md
- Update CODEOWNERs
- Update text-shortcuts extension (#14033)
- Update vade-mecum extension (#14104)
- Docs: Update the utils docs
- Update CODEOWNERs
- [Notion] Add LaunchContext support for Quick Capture (#13953)
- Update CODEOWNERs
- [Tailwind CSS] Add \`size\` utility classes (#14102)
- [GitHub] Brought back fast browsing to cloned repos. (#13992)
- Update CODEOWNERs
- Add git-buddy extension (#13116)
- Update CODEOWNERs
- [Raycast Notification] Added success and failure notification types (#13958)
- Update CODEOWNERs
- [Linkwarden] fix #13613 (API uses Bearer Auth) (#14070)
- Update olympic-games extension (#14090)
- Update CODEOWNERs
- Update folder search extension (#14077)
- Fix weekdays and change display method

* Update changelog

* Update cron extension

- Update Detail view
- Add detail and public holidays
- Update title and month to show no gap
- Docs: Update the utils docs
- Update CODEOWNERs
- Update CODEOWNERs
- Add Cursor.sh Doc extension (#14187)
- [Format GraphQL] new action to only format instead of format AND copy (#14217)
- Update CODEOWNERs
- Add metaphorpsum extension (#14124)
- Docs: Update the utils docs
- Update CODEOWNERs
- Add sql-format extension (#14144)
- Update CODEOWNERs
- Add say-no-to-notch extension (#14143)
- Update manifest.md (#14141)
- Add mood track (#14134)
- [NBA-Game-Viewer] Added scores to the viewer (#14188)
- Reduce calls to \`GET:/api/smart-habits\` (#14222)
- Update cron extension (#14199)
- Update CSS*GG (#14202)
- Update CODEOWNERs
- [SnippetSurfer] Make tags optional (#14197)
- Update CODEOWNERs
- [Wikipedia] Move \`igor9silva\` to past contributors (#14214)
- Update CODEOWNERs
- Update CODEOWNERs
- [NBA Game Viewer] Fixes for drop-down default values (#14205)
- [Envato] new logo + TS typing tweaks (minimize use of \`any\`) (#14034)
- [Luna Search] Add menu-bar command for quick access, move to hooks for retrieving data, fix pagination issue, add min-search size (#14174)
- Update CODEOWNERs
- Update Focus extension (#14204)
- Add forgejo extension (#14133)
- Update CODEOWNERs
- Add tidal-controller extension (#14130)
- Update CODEOWNERs
- [Google Maps Search] Travel mode fixes and improvements (#14128)
- Update CODEOWNERs
- Add readeck extension (#14109)
- Update CODEOWNERs
- [diskutil] Upgrades Raycast dependencies for failureToast fix (#14106)
- Update changelog
- #14189 - Fix date starting monday and update default colors

* Add changelog
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