<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abhishek Sharma</title>
    <description>The latest articles on DEV Community by Abhishek Sharma (@abhsss96).</description>
    <link>https://dev.to/abhsss96</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1784705%2F8f43ad70-bb4b-43ad-b27f-0083acfcfee7.jpg</url>
      <title>DEV Community: Abhishek Sharma</title>
      <link>https://dev.to/abhsss96</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhsss96"/>
    <language>en</language>
    <item>
      <title>Use your Obsidian vault from Neovim, organized by project</title>
      <dc:creator>Abhishek Sharma</dc:creator>
      <pubDate>Sun, 26 Apr 2026 16:51:00 +0000</pubDate>
      <link>https://dev.to/abhsss96/use-your-obsidian-vault-from-neovim-organized-by-project-3gm9</link>
      <guid>https://dev.to/abhsss96/use-your-obsidian-vault-from-neovim-organized-by-project-3gm9</guid>
      <description>&lt;p&gt;I built &lt;code&gt;notes-nvim&lt;/code&gt; because I wanted to use my Obsidian vault from inside Neovim without leaving my project.&lt;/p&gt;

&lt;p&gt;Obsidian is great for storing notes — graph view, mobile sync, plugin ecosystem. But my actual work happens in Neovim, and every Alt-Tab over to grab something from my vault was a small context-switch tax. Multiply that by a day of deep work and it adds up.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;notes-nvim&lt;/code&gt; points at any markdown directory — your existing Obsidian vault, a plain &lt;code&gt;~/notes&lt;/code&gt; folder, anything — and exposes it inside Neovim, organized automatically by project. When you're inside &lt;code&gt;my-api&lt;/code&gt;, your notes live under &lt;code&gt;my-api/&lt;/code&gt;. When you switch to &lt;code&gt;dotfiles&lt;/code&gt;, you're looking at &lt;code&gt;dotfiles/&lt;/code&gt;. Plain markdown, no custom format, your vault stays portable.&lt;/p&gt;




&lt;h2&gt;
  
  
  The core idea
&lt;/h2&gt;

&lt;p&gt;Most note plugins go one of two ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Project-local&lt;/strong&gt; — notes live inside the project folder. Clean in theory, but they end up in &lt;code&gt;.gitignore&lt;/code&gt; purgatory and scatter across dozens of repos.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Global flat pile&lt;/strong&gt; — one big notes folder. Works until you have 200 files and no way to filter by context.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;notes-nvim&lt;/code&gt; takes a third path: all notes live in &lt;strong&gt;one central directory&lt;/strong&gt; (&lt;code&gt;~/notes&lt;/code&gt; by default), but they're automatically &lt;strong&gt;organized by project root&lt;/strong&gt;. When you're inside &lt;code&gt;my-api&lt;/code&gt;, your notes go to &lt;code&gt;~/notes/my-api/&lt;/code&gt;. When you switch to &lt;code&gt;dotfiles&lt;/code&gt;, you're looking at &lt;code&gt;~/notes/dotfiles/&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/notes/                ← can be your existing Obsidian vault
  daily/                ← one shared daily log across all projects
    2026-04-26.md
    2026-04-25.md
  my-api/
    _index.md           ← auto-created, links to every note in the project
    auth.md
    api-design.md
  dotfiles/
    _index.md
    zsh.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You get the organization of project-local notes without the mess of scattering files across repos.&lt;/p&gt;




&lt;h2&gt;
  
  
  Using it with your existing Obsidian vault
&lt;/h2&gt;

&lt;p&gt;If you already have an Obsidian vault, point &lt;code&gt;notes-nvim&lt;/code&gt; straight at it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lua"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"abhsss96/notes-nvim"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;opts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;notes_dir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"~/Documents/ObsidianVault"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The plugin treats it like any markdown directory. Notes you create from Neovim show up in Obsidian on next open. Notes you create in Obsidian are searchable and openable from Neovim. Your vault stays a vault — Obsidian sync, mobile, and plugins keep working.&lt;/p&gt;

&lt;p&gt;Native Obsidian features like &lt;code&gt;[[wikilinks]]&lt;/code&gt; and embeds aren't fully resolved inside Neovim yet — that's the next big direction (more on this below).&lt;/p&gt;




&lt;h2&gt;
  
  
  Features at a glance
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Daily notes&lt;/strong&gt; — &lt;code&gt;:NoteToday&lt;/code&gt; opens today's &lt;code&gt;YYYY-MM-DD.md&lt;/code&gt;, shared globally across all projects&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Project index&lt;/strong&gt; — &lt;code&gt;_index.md&lt;/code&gt; is auto-created per project and backlinks every note you create&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Note from visual selection&lt;/strong&gt; — select code in visual mode, hit &lt;code&gt;&amp;lt;leader&amp;gt;ns&lt;/code&gt;, get a new note pre-populated with the snippet, source file, and line range&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Link-safe rename&lt;/strong&gt; — &lt;code&gt;:NoteRename&lt;/code&gt; updates every markdown link pointing to the old file&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tag search&lt;/strong&gt; — find notes by &lt;code&gt;#hashtag&lt;/code&gt; or YAML &lt;code&gt;tags:&lt;/code&gt; frontmatter&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Recent notes&lt;/strong&gt; — &lt;code&gt;:NoteRecent&lt;/code&gt; surfaces notes you visited lately via &lt;code&gt;oldfiles&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-picker&lt;/strong&gt; — works with snacks.nvim, telescope, fzf-lua, or the built-in &lt;code&gt;vim.ui.select&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;File browser&lt;/strong&gt; — opens in oil.nvim, nvim-tree, neo-tree, or netrw — whichever you have&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;snacks.dashboard integration&lt;/strong&gt; — show recent notes on your startup dashboard&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;which-key&lt;/strong&gt; — &lt;code&gt;&amp;lt;leader&amp;gt;n&lt;/code&gt; group registered automatically&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Health check&lt;/strong&gt; — &lt;code&gt;:checkhealth notes-nvim&lt;/code&gt; tells you what's wired up and what's missing&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;lazy.nvim&lt;/strong&gt; (recommended):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lua"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"abhsss96/notes-nvim"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;opts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;notes_dir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"~/notes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it for a working setup. The plugin auto-detects your fuzzy picker and file browser — no extra wiring required for most setups.&lt;/p&gt;




&lt;h2&gt;
  
  
  Commands and keymaps
&lt;/h2&gt;

&lt;p&gt;All commands are available as both Ex commands and keymaps under &lt;code&gt;&amp;lt;leader&amp;gt;n&lt;/code&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Keymap&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:Note [name]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;leader&amp;gt;no&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Open or create a note in the current project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteToday&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;leader&amp;gt;nt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Open today's daily note&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteIndex&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;leader&amp;gt;ni&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Open &lt;code&gt;_index.md&lt;/code&gt; for the current project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteFind&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;leader&amp;gt;np&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fuzzy-find notes in the current project&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteFindAll&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;leader&amp;gt;na&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fuzzy-find notes across all projects&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteRecent&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;leader&amp;gt;nr&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Browse recently opened notes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteBrowse&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;leader&amp;gt;nb&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Open project notes folder in your file browser&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteGrep&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;leader&amp;gt;ng&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Live-grep inside the current project's notes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteGrepAll&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;leader&amp;gt;nG&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Live-grep across all notes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteFindByTag&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;Pick a tag and jump to matching notes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteFromSelection&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;leader&amp;gt;ns&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create a note from a visual selection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;:NoteRename [name]&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;td&gt;Rename the current note and rewrite all links&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  The feature I use most: Note from selection
&lt;/h2&gt;

&lt;p&gt;This is the workflow killer that made me build the plugin in the first place.&lt;/p&gt;

&lt;p&gt;You're reading through code — maybe debugging, maybe doing a review — and you land on a function you need to reason about later. Select it in visual mode, press &lt;code&gt;&amp;lt;leader&amp;gt;ns&lt;/code&gt;, give the note a name, and you get this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# Authenticate function&lt;/span&gt;

Created: 2026-04-26

Source: &lt;span class="sb"&gt;`src/auth.lua`&lt;/span&gt; lines 42–58
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lua"&gt;&lt;code&gt;&lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;authenticate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;local&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;find_token&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;expires_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;os.time&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"token expired"&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source file, line range, and filetype are all captured automatically. Your future self will know exactly where this came from.&lt;/p&gt;




&lt;h2&gt;
  
  
  Tag search
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;notes-nvim&lt;/code&gt; understands two tag formats so you don't have to pick one:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;YAML frontmatter:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;span class="na"&gt;tags&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;neovim&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;workflow&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;auth&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
&lt;span class="nn"&gt;---&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Inline hashtags:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Ran into a weird edge case with token refresh. #auth #debugging
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;:NoteFindByTag&lt;/code&gt; scans both formats and gives you a picker of all tags in the current project. &lt;code&gt;:NoteFindByTagAll&lt;/code&gt; does the same globally.&lt;/p&gt;




&lt;h2&gt;
  
  
  Custom templates
&lt;/h2&gt;

&lt;p&gt;New notes are created from a Lua template function, so you can inject whatever frontmatter or boilerplate you want:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lua"&gt;&lt;code&gt;&lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"notes-nvim"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="n"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;string.format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;[[
---
title: %s
project: %s
date: %s
tags: []
---

# %s

]]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;project&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;ctx&lt;/code&gt; table has &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;filepath&lt;/code&gt;, &lt;code&gt;project&lt;/code&gt;, and &lt;code&gt;date&lt;/code&gt; — enough to build most templates.&lt;/p&gt;




&lt;h2&gt;
  
  
  snacks.dashboard integration
&lt;/h2&gt;

&lt;p&gt;If you use snacks.nvim, you can show recent notes right on your startup screen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight lua"&gt;&lt;code&gt;&lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"snacks"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;setup&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="n"&gt;dashboard&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;sections&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;section&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"header"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;section&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"keys"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"notes-nvim.dashboard"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;snacks_section&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="n"&gt;limit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Recent Notes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;}),&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;section&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"startup"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  What I want to build next — and where I'd love input
&lt;/h2&gt;

&lt;p&gt;This is where you come in. &lt;code&gt;notes-nvim&lt;/code&gt; is at v1.0 and the core workflow is solid, but there's a lot of room to grow. The biggest direction I'm focused on next:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deeper Obsidian compatibility&lt;/strong&gt; — &lt;code&gt;[[wikilink]]&lt;/code&gt; resolution and navigation, alias support from frontmatter, embed (&lt;code&gt;![[file]]&lt;/code&gt;) handling, and other vault-native features. The goal is for &lt;code&gt;notes-nvim&lt;/code&gt; to be a first-class Obsidian companion inside Neovim, not just a markdown reader.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A few other things on the list:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Templates per project&lt;/strong&gt; — different boilerplate for different project types (e.g., a meeting note template for work projects, a learning note for side projects)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Note linking / backlinks&lt;/strong&gt; — jump to all notes that link to the current one&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inline preview&lt;/strong&gt; — float a preview of a linked note on hover&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Export&lt;/strong&gt; — push a note or a project's notes to a markdown directory ready for a static site&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Git integration&lt;/strong&gt; — auto-commit notes directory on save, or show a diff of today's notes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Note archiving&lt;/strong&gt; — move old notes to an archive without breaking links&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you use both Obsidian and Neovim, I'd especially love to hear what's missing for you. Which Obsidian features do you reach for most that you'd want inside Neovim? And for Neovim users without an Obsidian vault — what does your current note setup look like, and what's the one thing that still makes you reach for an external app?&lt;/p&gt;

&lt;p&gt;Drop a comment below — I read all of them and a good chunk of the features above came from conversations with other Neovim users.&lt;/p&gt;




&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;GitHub: &lt;a href="https://github.com/abhsss96/notes-nvim" rel="noopener noreferrer"&gt;abhsss96/notes-nvim&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Issues and feature requests: &lt;a href="https://github.com/abhsss96/notes-nvim/issues" rel="noopener noreferrer"&gt;github.com/abhsss96/notes-nvim/issues&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Built with Lua. Tested on Neovim 0.9+. MIT licensed.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>neovim</category>
      <category>obsidian</category>
      <category>showdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Switch Your Samsung M8 Monitor HDMI Inputs from the Terminal (No Remote Needed)</title>
      <dc:creator>Abhishek Sharma</dc:creator>
      <pubDate>Fri, 17 Apr 2026 05:28:05 +0000</pubDate>
      <link>https://dev.to/abhsss96/switch-your-samsung-m8-monitor-hdmi-inputs-from-the-terminal-no-remote-needed-4i84</link>
      <guid>https://dev.to/abhsss96/switch-your-samsung-m8-monitor-hdmi-inputs-from-the-terminal-no-remote-needed-4i84</guid>
      <description>&lt;p&gt;If you run two machines — a work laptop and a personal desktop — connected to a Samsung M8, you already know the pain: reach for the remote, navigate the OSD menu, switch source, repeat twenty times a day. Here's how to collapse that into a single terminal command using the &lt;strong&gt;SmartThings CLI&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The best part: this approach works identically on both &lt;strong&gt;macOS and Linux&lt;/strong&gt; since it's Node.js-based.&lt;/p&gt;




&lt;h2&gt;
  
  
  How This Works
&lt;/h2&gt;

&lt;p&gt;The Samsung M8 is a SmartThings-connected display. Samsung exposes a first-party CLI — &lt;code&gt;@smartthings/cli&lt;/code&gt; — that can send commands to any registered SmartThings device, including input source switching on the M8. No hacking, no reverse engineering, no X11 tools.&lt;/p&gt;




&lt;h2&gt;
  
  
  What You Need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Samsung M8 monitor connected to your SmartThings account&lt;/li&gt;
&lt;li&gt;Node.js (we'll use &lt;code&gt;asdf&lt;/code&gt; for version management)&lt;/li&gt;
&lt;li&gt;SmartThings CLI installed globally via npm&lt;/li&gt;
&lt;li&gt;Your M8's SmartThings device ID&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 1: Install Node.js via asdf
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;asdf&lt;/code&gt; works the same on macOS and Linux, which is why it's the cleanest approach here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;macOS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;asdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Linux (Ubuntu/Debian):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;curl git
git clone https://github.com/asdf-vm/asdf.git ~/.asdf &lt;span class="nt"&gt;--branch&lt;/span&gt; v0.14.0
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'. "$HOME/.asdf/asdf.sh"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then install Node.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin add nodejs
asdf &lt;span class="nb"&gt;install &lt;/span&gt;nodejs 24.13.0
asdf global nodejs 24.13.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;--version&lt;/span&gt;   &lt;span class="c"&gt;# v24.13.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 2: Install the SmartThings CLI
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @smartthings/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;smartthings &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 3: Authenticate with SmartThings
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;smartthings devices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open a browser and ask you to log in with your Samsung account. After authentication, it lists all your SmartThings devices.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Find Your M8 Device ID
&lt;/h2&gt;

&lt;p&gt;After authentication, &lt;code&gt;smartthings devices&lt;/code&gt; outputs a table. Find your Samsung M8 and copy its device ID — it looks like a UUID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────┬─────────────────┬──────────────────────────────────────┐
│ #  │ Label           │ Device ID                            │
├────┼─────────────────┼──────────────────────────────────────┤
│  1 │ Samsung M8      │ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx │
└────┴─────────────────┴──────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Export it in your &lt;code&gt;~/.zshrc.local&lt;/code&gt; (keep it out of your dotfiles repo since it's device-specific):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;SMARTTHINGS_MONITOR_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 5: The Toggle Script
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;~/dotfiles/scripts/monitor_input.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# Control Samsung M8 monitor input via SmartThings CLI&lt;/span&gt;
&lt;span class="c"&gt;# Requires: smartthings CLI + SMARTTHINGS_MONITOR_ID env var set in ~/.zshrc.local&lt;/span&gt;

_smartthings_cmd&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;st_bin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.asdf/installs/nodejs/24.13.0/bin/smartthings"&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$st_bin&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$st_bin&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$@&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nb"&gt;command &lt;/span&gt;smartthings &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$@&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

_monitor_check&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; _smartthings_cmd &lt;span class="nt"&gt;--version&lt;/span&gt; &amp;amp;&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"smartthings CLI not found."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Run: npm install -g @smartthings/cli"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="k"&gt;fi
  if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SMARTTHINGS_MONITOR_ID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"SMARTTHINGS_MONITOR_ID is not set."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Run: smartthings devices   → find your M8 device ID"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Then add to ~/.zshrc.local:  export SMARTTHINGS_MONITOR_ID='&amp;lt;id&amp;gt;'"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

monitor_hdmi1&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  _monitor_check &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Switching to HDMI 1..."&lt;/span&gt;
  _smartthings_cmd devices:commands &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SMARTTHINGS_MONITOR_ID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s1"&gt;'main:mediaInputSource:setInputSource("HDMI1")'&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

monitor_hdmi2&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  _monitor_check &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Switching to HDMI 2..."&lt;/span&gt;
  _smartthings_cmd devices:commands &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SMARTTHINGS_MONITOR_ID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s1"&gt;'main:mediaInputSource:setInputSource("HDMI2")'&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

monitor_toggle&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  _monitor_check &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="nb"&gt;local &lt;/span&gt;current
  &lt;span class="nv"&gt;current&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;_smartthings_cmd devices:status &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SMARTTHINGS_MONITOR_ID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null &lt;span class="se"&gt;\&lt;/span&gt;
    | jq &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'.components.main."samsungvd.mediaInputSource".inputSource.value // empty'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$current&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Could not read current input source."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="k"&gt;fi

  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Current input: &lt;/span&gt;&lt;span class="nv"&gt;$current&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$current&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"HDMI1"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;monitor_hdmi2
  &lt;span class="k"&gt;else
    &lt;/span&gt;monitor_hdmi1
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Allow running directly: ./monitor_input.sh [hdmi1|hdmi2|toggle]&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;:-}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in
  &lt;/span&gt;hdmi1&lt;span class="p"&gt;)&lt;/span&gt;  monitor_hdmi1 &lt;span class="p"&gt;;;&lt;/span&gt;
  hdmi2&lt;span class="p"&gt;)&lt;/span&gt;  monitor_hdmi2 &lt;span class="p"&gt;;;&lt;/span&gt;
  toggle&lt;span class="p"&gt;)&lt;/span&gt; monitor_toggle &lt;span class="p"&gt;;;&lt;/span&gt;
  &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usage: &lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt; [hdmi1|hdmi2|toggle]"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  or source this file and call monitor_hdmi1 / monitor_hdmi2 / monitor_toggle"&lt;/span&gt;
    &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A couple of things worth noting in &lt;code&gt;_smartthings_cmd&lt;/code&gt;: it tries the asdf-managed binary path first, then falls back to whatever &lt;code&gt;smartthings&lt;/code&gt; is on &lt;code&gt;$PATH&lt;/code&gt;. This means the script works whether you're using asdf or a global npm install.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 6: Wire Up the Aliases
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;~/dotfiles/zsh/aliases/monitor.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# ── Samsung M8 Monitor Input (SmartThings) ──────────────────────────────────&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;command&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; smartthings &amp;amp;&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/dotfiles/scripts/monitor_input.sh"&lt;/span&gt; 2&amp;gt;/dev/null

  &lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;hdmi1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'monitor_hdmi1'&lt;/span&gt;
  &lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;hdmi2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'monitor_hdmi2'&lt;/span&gt;
  &lt;span class="nb"&gt;alias &lt;/span&gt;hdmi-toggle&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'monitor_toggle'&lt;/span&gt;
  &lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;t&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'monitor_toggle'&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source it from your &lt;code&gt;.zshrc&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/dotfiles/zsh/aliases/monitor.sh"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;command -v smartthings&lt;/code&gt; guard means the aliases are silently skipped on any machine that doesn't have the CLI installed — no errors, no noise.&lt;/p&gt;




&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hdmi1         &lt;span class="c"&gt;# switch to HDMI 1 (machine A)&lt;/span&gt;
hdmi2         &lt;span class="c"&gt;# switch to HDMI 2 (machine B)&lt;/span&gt;
hdmi-toggle   &lt;span class="c"&gt;# toggle between whichever is active&lt;/span&gt;
t             &lt;span class="c"&gt;# same as hdmi-toggle, just shorter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it directly without sourcing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;~/dotfiles/scripts/monitor_input.sh toggle
~/dotfiles/scripts/monitor_input.sh hdmi1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Workflow in Practice
&lt;/h2&gt;

&lt;p&gt;My setup: work MacBook on HDMI 1, personal Linux desktop on HDMI 2. A single &lt;code&gt;t&lt;/code&gt; in the terminal and the monitor switches — no remote, no OSD, no context switch. Since it goes through SmartThings rather than DDC/CI, it works over the network too, so you don't even need to be in the same session as the machine you're switching away from.&lt;/p&gt;




&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;smartthings CLI not found&lt;/code&gt;&lt;/strong&gt; — Make sure the npm global bin is on your &lt;code&gt;$PATH&lt;/code&gt;. Check with &lt;code&gt;npm bin -g&lt;/code&gt; and add it to your shell profile if missing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;SMARTTHINGS_MONITOR_ID is not set&lt;/code&gt;&lt;/strong&gt; — Add the export to &lt;code&gt;~/.zshrc.local&lt;/code&gt; (not your dotfiles repo) and re-source your shell.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Could not read current input source&lt;/code&gt;&lt;/strong&gt; — Run &lt;code&gt;smartthings devices:status $SMARTTHINGS_MONITOR_ID&lt;/code&gt; manually to inspect the raw JSON. The capability key may differ slightly on older M8 firmware; look for &lt;code&gt;mediaInputSource&lt;/code&gt; in the output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commands time out&lt;/strong&gt; — The M8 needs to be on and connected to your Wi-Fi network. Wake it from standby first, or disable deep sleep in the monitor's power settings.&lt;/p&gt;




&lt;p&gt;That's it. SmartThings CLI, one script, four aliases, zero remote-reaching.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Full script and aliases live in my dotfiles: &lt;a href="https://github.com/abhsss96/dotfiles" rel="noopener noreferrer"&gt;github.com/abhsss96/dotfiles&lt;/a&gt; — see &lt;code&gt;scripts/monitor_input.sh&lt;/code&gt; and &lt;code&gt;zsh/aliases/monitor.sh&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>productivity</category>
      <category>terminal</category>
      <category>tooling</category>
    </item>
    <item>
      <title>Switch Your Samsung M8 Monitor Inputs from the Terminal (No Remote Needed)</title>
      <dc:creator>Abhishek Sharma</dc:creator>
      <pubDate>Fri, 17 Apr 2026 05:22:37 +0000</pubDate>
      <link>https://dev.to/abhsss96/switch-your-samsung-m8-monitor-inputs-from-the-terminal-no-remote-needed-48lk</link>
      <guid>https://dev.to/abhsss96/switch-your-samsung-m8-monitor-inputs-from-the-terminal-no-remote-needed-48lk</guid>
      <description>&lt;p&gt;If you run two machines — a work laptop and a personal desktop — connected to a Samsung M8, you already know the pain: reach for the remote, navigate the OSD menu, switch source, repeat twenty times a day. Here's how to collapse that into a single terminal command using the &lt;strong&gt;SmartThings CLI&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The best part: this approach works identically on both &lt;strong&gt;macOS and Linux&lt;/strong&gt; since it's Node.js-based.&lt;/p&gt;




&lt;h2&gt;
  
  
  How This Works
&lt;/h2&gt;

&lt;p&gt;The Samsung M8 is a SmartThings-connected display. Samsung exposes a first-party CLI — &lt;code&gt;@smartthings/cli&lt;/code&gt; — that can send commands to any registered SmartThings device, including input source switching on the M8. No hacking, no reverse engineering, no X11 tools.&lt;/p&gt;




&lt;h2&gt;
  
  
  What You Need
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Samsung M8 monitor connected to your SmartThings account&lt;/li&gt;
&lt;li&gt;Node.js (we'll use &lt;code&gt;asdf&lt;/code&gt; for version management)&lt;/li&gt;
&lt;li&gt;SmartThings CLI installed globally via npm&lt;/li&gt;
&lt;li&gt;Your M8's SmartThings device ID&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 1: Install Node.js via asdf
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;asdf&lt;/code&gt; works the same on macOS and Linux, which is why it's the cleanest approach here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;macOS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;asdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Linux (Ubuntu/Debian):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;curl git
git clone https://github.com/asdf-vm/asdf.git ~/.asdf &lt;span class="nt"&gt;--branch&lt;/span&gt; v0.14.0
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'. "$HOME/.asdf/asdf.sh"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.zshrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then install Node.js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin add nodejs
asdf &lt;span class="nb"&gt;install &lt;/span&gt;nodejs 24.13.0
asdf global nodejs 24.13.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;node &lt;span class="nt"&gt;--version&lt;/span&gt;   &lt;span class="c"&gt;# v24.13.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 2: Install the SmartThings CLI
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @smartthings/cli
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;smartthings &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 3: Authenticate with SmartThings
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;smartthings devices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will open a browser and ask you to log in with your Samsung account. After authentication, it lists all your SmartThings devices.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Find Your M8 Device ID
&lt;/h2&gt;

&lt;p&gt;After authentication, &lt;code&gt;smartthings devices&lt;/code&gt; outputs a table. Find your Samsung M8 and copy its device ID — it looks like a UUID:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────┬─────────────────┬──────────────────────────────────────┐
│ #  │ Label           │ Device ID                            │
├────┼─────────────────┼──────────────────────────────────────┤
│  1 │ Samsung M8      │ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx │
└────┴─────────────────┴──────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Export it in your &lt;code&gt;~/.zshrc.local&lt;/code&gt; (keep it out of your dotfiles repo since it's device-specific):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;SMARTTHINGS_MONITOR_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Step 5: The Toggle Script
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;~/dotfiles/scripts/monitor_input.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;
&lt;span class="c"&gt;# Control Samsung M8 monitor input via SmartThings CLI&lt;/span&gt;
&lt;span class="c"&gt;# Requires: smartthings CLI + SMARTTHINGS_MONITOR_ID env var set in ~/.zshrc.local&lt;/span&gt;

_smartthings_cmd&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;st_bin&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.asdf/installs/nodejs/24.13.0/bin/smartthings"&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-x&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$st_bin&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$st_bin&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$@&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nb"&gt;command &lt;/span&gt;smartthings &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$@&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

_monitor_check&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; _smartthings_cmd &lt;span class="nt"&gt;--version&lt;/span&gt; &amp;amp;&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"smartthings CLI not found."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Run: npm install -g @smartthings/cli"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="k"&gt;fi
  if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SMARTTHINGS_MONITOR_ID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"SMARTTHINGS_MONITOR_ID is not set."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Run: smartthings devices   → find your M8 device ID"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Then add to ~/.zshrc.local:  export SMARTTHINGS_MONITOR_ID='&amp;lt;id&amp;gt;'"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

monitor_hdmi1&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  _monitor_check &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Switching to HDMI 1..."&lt;/span&gt;
  _smartthings_cmd devices:commands &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SMARTTHINGS_MONITOR_ID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s1"&gt;'main:mediaInputSource:setInputSource("HDMI1")'&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

monitor_hdmi2&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  _monitor_check &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Switching to HDMI 2..."&lt;/span&gt;
  _smartthings_cmd devices:commands &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SMARTTHINGS_MONITOR_ID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s1"&gt;'main:mediaInputSource:setInputSource("HDMI2")'&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

monitor_toggle&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  _monitor_check &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="nb"&gt;local &lt;/span&gt;current
  &lt;span class="nv"&gt;current&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;_smartthings_cmd devices:status &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$SMARTTHINGS_MONITOR_ID&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null &lt;span class="se"&gt;\&lt;/span&gt;
    | jq &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'.components.main."samsungvd.mediaInputSource".inputSource.value // empty'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$current&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Could not read current input source."&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&amp;amp;2
    &lt;span class="k"&gt;return &lt;/span&gt;1
  &lt;span class="k"&gt;fi

  &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Current input: &lt;/span&gt;&lt;span class="nv"&gt;$current&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$current&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"HDMI1"&lt;/span&gt; &lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;monitor_hdmi2
  &lt;span class="k"&gt;else
    &lt;/span&gt;monitor_hdmi1
  &lt;span class="k"&gt;fi&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Allow running directly: ./monitor_input.sh [hdmi1|hdmi2|toggle]&lt;/span&gt;
&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;1&lt;/span&gt;&lt;span class="k"&gt;:-}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="k"&gt;in
  &lt;/span&gt;hdmi1&lt;span class="p"&gt;)&lt;/span&gt;  monitor_hdmi1 &lt;span class="p"&gt;;;&lt;/span&gt;
  hdmi2&lt;span class="p"&gt;)&lt;/span&gt;  monitor_hdmi2 &lt;span class="p"&gt;;;&lt;/span&gt;
  toggle&lt;span class="p"&gt;)&lt;/span&gt; monitor_toggle &lt;span class="p"&gt;;;&lt;/span&gt;
  &lt;span class="k"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usage: &lt;/span&gt;&lt;span class="nv"&gt;$0&lt;/span&gt;&lt;span class="s2"&gt; [hdmi1|hdmi2|toggle]"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  or source this file and call monitor_hdmi1 / monitor_hdmi2 / monitor_toggle"&lt;/span&gt;
    &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="k"&gt;esac&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A couple of things worth noting in &lt;code&gt;_smartthings_cmd&lt;/code&gt;: it tries the asdf-managed binary path first, then falls back to whatever &lt;code&gt;smartthings&lt;/code&gt; is on &lt;code&gt;$PATH&lt;/code&gt;. This means the script works whether you're using asdf or a global npm install.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 6: Wire Up the Aliases
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;~/dotfiles/zsh/aliases/monitor.sh&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# ── Samsung M8 Monitor Input (SmartThings) ──────────────────────────────────&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="nb"&gt;command&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; smartthings &amp;amp;&amp;gt;/dev/null&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
  &lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/dotfiles/scripts/monitor_input.sh"&lt;/span&gt; 2&amp;gt;/dev/null

  &lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;hdmi1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'monitor_hdmi1'&lt;/span&gt;
  &lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;hdmi2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'monitor_hdmi2'&lt;/span&gt;
  &lt;span class="nb"&gt;alias &lt;/span&gt;hdmi-toggle&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'monitor_toggle'&lt;/span&gt;
  &lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;t&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'monitor_toggle'&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Source it from your &lt;code&gt;.zshrc&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/dotfiles/zsh/aliases/monitor.sh"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;command -v smartthings&lt;/code&gt; guard means the aliases are silently skipped on any machine that doesn't have the CLI installed — no errors, no noise.&lt;/p&gt;




&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;hdmi1         &lt;span class="c"&gt;# switch to HDMI 1 (machine A)&lt;/span&gt;
hdmi2         &lt;span class="c"&gt;# switch to HDMI 2 (machine B)&lt;/span&gt;
hdmi-toggle   &lt;span class="c"&gt;# toggle between whichever is active&lt;/span&gt;
t             &lt;span class="c"&gt;# same as hdmi-toggle, just shorter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run it directly without sourcing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;~/dotfiles/scripts/monitor_input.sh toggle
~/dotfiles/scripts/monitor_input.sh hdmi1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Workflow in Practice
&lt;/h2&gt;

&lt;p&gt;My setup: work MacBook on HDMI 1, personal Linux desktop on HDMI 2. A single &lt;code&gt;t&lt;/code&gt; in the terminal and the monitor switches — no remote, no OSD, no context switch. Since it goes through SmartThings rather than DDC/CI, it works over the network too, so you don't even need to be in the same session as the machine you're switching away from.&lt;/p&gt;




&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;smartthings CLI not found&lt;/code&gt;&lt;/strong&gt; — Make sure the npm global bin is on your &lt;code&gt;$PATH&lt;/code&gt;. Check with &lt;code&gt;npm bin -g&lt;/code&gt; and add it to your shell profile if missing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;SMARTTHINGS_MONITOR_ID is not set&lt;/code&gt;&lt;/strong&gt; — Add the export to &lt;code&gt;~/.zshrc.local&lt;/code&gt; (not your dotfiles repo) and re-source your shell.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;Could not read current input source&lt;/code&gt;&lt;/strong&gt; — Run &lt;code&gt;smartthings devices:status $SMARTTHINGS_MONITOR_ID&lt;/code&gt; manually to inspect the raw JSON. The capability key may differ slightly on older M8 firmware; look for &lt;code&gt;mediaInputSource&lt;/code&gt; in the output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commands time out&lt;/strong&gt; — The M8 needs to be on and connected to your Wi-Fi network. Wake it from standby first, or disable deep sleep in the monitor's power settings.&lt;/p&gt;




&lt;p&gt;That's it. SmartThings CLI, one script, four aliases, zero remote-reaching.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Full script and aliases live in my dotfiles: &lt;a href="https://github.com/abhsss96/dotfiles" rel="noopener noreferrer"&gt;github.com/abhsss96/dotfiles&lt;/a&gt; — see &lt;code&gt;scripts/monitor_input.sh&lt;/code&gt; and &lt;code&gt;zsh/aliases/monitor.sh&lt;/code&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>productivity</category>
      <category>terminal</category>
      <category>mac</category>
    </item>
  </channel>
</rss>
