# \[Mobile\] Dynamic mobile pulldown action using CodeScript Toolkit

**URL:** <https://forum.obsidian.md/t/mobile-dynamic-mobile-pulldown-action-using-codescript-toolkit/101422>\
**Category:** Workflows & Templates\
**Tags:** ui-ux\
**Created:** [June 2, 2025, 3:42am UTC](https://forum.obsidian.md/t/mobile-dynamic-mobile-pulldown-action-using-codescript-toolkit/101422 "2025-06-02T03:42:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abisheik](https://forum.obsidian.md/user_avatar/forum.obsidian.md/abisheik/32/46914_2.png) [@Abisheik](https://forum.obsidian.md/u/Abisheik)\
**Post date:** [June 2, 2025, 3:42am UTC](https://forum.obsidian.md/t/mobile-dynamic-mobile-pulldown-action-using-codescript-toolkit/101422/1 "2025-06-02T03:42:51Z")

</div>

I’ve been kinda obsessed with [CodeScript Toolkit](https://github.com/mnaoumov/obsidian-codescript-toolkit) lately. With the ability to set scripts as “invocable,” you can set a script to your mobile pulldown action.

Here’s a script that:

- If in a markdown file
  - If not in editing mode
    - If a tablet
      - Open [Quick Switcher++](https://github.com/darlal/obsidian-switcher-plus)

    - If a phone
      - Close the tab

  - If in editing mode
    - If a tablet
      - Open Quick Switcher++

    - If a phone
      - Toggle voice recording (start recording if not recording, stop recording if recording)

- If in a Canvas file
  - If a tablet
    - Open Quick Switcher++

  - If a phone
    - Search the file (possible due to the [Advanced Canvas](https://github.com/Developer-Mike/obsidian-advanced-canvas) plugin)

- If not in a markdown nor in a Canvas file
  - Open Quick Switcher++

You might be thinking all that “if a tablet → open Quick Switcher++” is redundant and you’re right, but it’s set up like that in case I have better ideas and want to change it later. I have a foldable phone so I wanted to have the pulldown do different things when my phone is unfolded.

Anyway, here’s the script!

```js
exports.invoke = async (app) => {
	const currentfileextension = app.workspace?.activeLeaf?.view?.file?.extension
	if (currentfileextension === 'md') {
		const mode = app.workspace.activeLeaf.view.currentMode?.type;
		if (!mode) return;
	
		if (mode !== 'source') {
			if (document.body.classList.contains('is-tablet')) {
				app.commands.executeCommandById('darlal-switcher-plus:switcher-plus:open');
			} else {
				app.commands.executeCommandById('workspace:close');
			}
			return;
		}
	
		if (document.body.classList.contains('is-tablet')) {
			app.commands.executeCommandById('darlal-switcher-plus:switcher-plus:open');
		} else {
			const audioPlugin = app.internalPlugins.plugins['audio-recorder']?.instance;
			const isRecording = Boolean(audioPlugin?.recording);
		
			if (isRecording) {
				app.commands.executeCommandById('audio-recorder:stop');
				new Notice('⏹️ Recording stopped');
			} else {
				app.commands.executeCommandById('audio-recorder:start');
				new Notice('🔴 Recording started');
			}
		}
		return;
	}
	
	if (currentfileextension === 'canvas') {
		if (document.body.classList.contains('is-tablet')) {
			app.commands.executeCommandById('darlal-switcher-plus:switcher-plus:open');
		} else {
			app.commands.executeCommandById('editor:open-search');
		}
		return;
	}
	
	app.commands.executeCommandById('darlal-switcher-plus:switcher-plus:open');
};

```

---

<div class="post-metadata">

**Author:** ![lily75dom](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/l/977dab/32.png) [@lily75dom](https://forum.obsidian.md/u/lily75dom)\
**Post date:** [June 9, 2025, 6:29am UTC](https://forum.obsidian.md/t/mobile-dynamic-mobile-pulldown-action-using-codescript-toolkit/101422/2 "2025-06-09T06:29:46Z")

</div>

This info really helps me.

---

<div class="post-metadata">

**Author:** ![Abisheik](https://forum.obsidian.md/user_avatar/forum.obsidian.md/abisheik/32/46914_2.png) [@Abisheik](https://forum.obsidian.md/u/Abisheik)\
**Post date:** [July 16, 2025, 9:11pm UTC](https://forum.obsidian.md/t/mobile-dynamic-mobile-pulldown-action-using-codescript-toolkit/101422/3 "2025-07-16T21:11:30Z")

</div>

By the way, to get the command IDs for every command palette command, run  
`console.log(Object.keys(app.commands.commands))`  
then, in your script, you can use it like  
`app.commands.executeCommandById('workspace:edit-file-title')`\[1\].

* * *

1. This goes into editing the current file’s title.
