• This repository has been archived on 20/Feb/2020
  • Stars
    star
    390
  • Rank 109,491 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Tiny web-based mastodon client for your desktop

Web-based Desktop Client for Mastodon

npm version

Mstdn is a desktop application based on the mobile version of the Mastodon page and the Electron framework. It basically uses Mastodon's mobile page and provides various desktop application features (such as desktop notifications, keybindings, and multi-account support).

screen shot

Features:

  • Small window on your menubar (or isolated normal window)
  • Desktop notification
  • Customizable (and pluggable) shortcut keybinds
  • Multi-account (switching among accounts)
  • User CSS
  • Plugin architecture based on Node.js and Electron APIs

Mastodon is an open source project. So if you want to make a new UI, you can just fork the project, implement your favorite UI and host it on your place. Then you can participate Mastodon networks from it.

However, Mastodon is a web application. So we can't use it outside of a browser. This small tool provides the ability to use the Mastodon page in a desktop application window outside of a browser.

Installation

Via npm

$ npm install -g mstdn

Via yarn

$ yarn global add mstdn --prefix /usr/local

As an isolated app

Download a package archive from the Release page, put the unarchived app into the proper place, and open it.

Arch Linux (AUR)

Install the mstdn package from the AUR.

Usage

If you installed this app via npm or yarn, the following command is available to start app:

$ open-mstdn-app

At first, a dialog which recommends that you create a config is shown and JSON config file will be opened in your editor. You need to fill in the "name" and "host" keys in first element of "accounts". Please see the accounts section below for more information about how to configure the option.

Then please try to start app again. Usage is the same as web client on mobile devices. Some shortcuts are available by default (please see the 'Customization' section below).

Supported platforms are macOS (confirmed with 10.12), Linux (confirmed on Arch Linux kernel version 4.11) and Windows (confirmed with Windows 8.1).

There are two window modes in this app: 'menubar mode' and 'normal window mode'. You can switch them with "normal_window" option (please see below 'Customization' section for how to configure it).

  • menubar mode: Window is attached to the menubar. You can toggle the window by clicking the menubar icon or typing the hot key. The advantage of this mode is that the app does not fill any workspaces. You can see your timeline on demand anytime. Like as menus in menubar on macOS, menubar window is automatically hidden when it loses its focus. This mode is the default on macOS and Linux.
  • normal window mode: App starts with a normal window like a separated browser window. You can put/resize window wherever you would like in your workspace.

In both modes, the app remembers the size and location of its window. So you need to specify window size (or location in normal window mode) only once.

After starting the app, you would see the login page of your instance. Some instances allow to login with other web services. However, Mstdn.app cannot fully support it. If you encounter problems with a customized login feature, please try to login with normal flow instead.

Customization

Mstdn can be customized using the JSON config file at {app dir}/config.json

The {app dir} is:

  • ~/Library/Application\ Support/Mstdn for macOS
  • ~/.config/Mstdn for Linux
  • %APPDATA%\Mstdn for Windows.

The JSON file can contain the following key-values:

hot_key

hot_key is a key sequence to toggle application window. The shortcut key is defined globally. The format is an Electron's accelerator. Please see the document to know how to configure this value. Default value is "CmdOrCtrl+Shift+Enter". If you want to disable, please set this value to an empty string or null.

icon_color

The color of icon in menubar. "black" or "white" can be specified.

always_on_top

When this value is set to true, the window won't be hidden if it loses a focus. Default value is false.

normal_window

When this value is set to true, application will be launched as a normal window application. If the menu bar behavior does not work for you, please set this value to true to avoid it. Default value is false on macOS or Linux, true on Windows because window position is broken in some versions of Windows.

hide_menu

When this value is set to true, the application will be launched with the menubar hidden, assuming normal_window is also true. When set to false, the menubar will be visible on launch. Default value is false.

On Windows, typing Alt key shows the hidden menubar.

zoom_factor

Font zoom factor in application. It should be positive number. For example, 0.7 means 70% font zooming. Default font size is a bit bigger because the UI is originally for mobile devices. So default value is 0.9.

accounts

Array of your accounts. Each element should have "name", "host" and "default_page" keys.

  • "name" represents your screen name. If your name is @foo then please specify "foo" for it.

  • "host" represents a host part of URL of your mastodon instance. If you belong to https://mastodon.social, please specify mastodon.social. https:// is not necessary.

  • "default_page" is a path of the first shown page on app start. If /web/notifications is specified, https://{your host}/web/notifications will be opened when the app starts.

You need to write up this config at first.

chromium_sandbox

If true is specified, Chromium's native sandbox is enabled (and default value is true). Sandbox provides some OS level security protection such as resource access control like tabs in Chromium. However, sandbox also blocks plugins for Electron application.

If false is specified, you can use some advanced features (user CSS and key shortcut plugin). Before setting false to this value, please read and understand sandbox documentation in Electron repo to know what you're doing.

Please note that this sandbox feature is different from Node.js integration in Electron. Node.js integration is always disabled.

keymaps

Object whose key is a key sequence and whose value is an action name.

Action Name Description Default Key
scroll-down Scroll down window j
scroll-up Scroll up window k
scroll-top Scroll up to top of window i
scroll-bottom Scroll down to bottom of window m
next-account Switch to next account N/A
prev-account Switch to previous account N/A
open-in-browser Open current page in browser N/A

If an action name starts with /, it will navigate to the path. For example, if you set "/web/timelines/home" to some key shortcut and you input the key, browser will navigate page to https://{your host}/web/timelines/home.

Below is a default path actions. They are corresponding the position of tab items.

Path Description Default Key
/web/statuses/new Move to 'make a new toot' page 1
/web/timelines/home Move to 'home timeline' page 2
/web/notifications Move to 'notifications' page 3
/web/timelines/public/local Move to 'local timeline' page 4
/web/timelines/public Move to 'federated timeline' page 5
/web/getting-started Move to 'getting started' page 6

If an action name ends with .js, it will run key shortcut plugin (please see below 'Key Shortcut Plugin' section). This plugin feature requires "chromium_sandbox": true.

By default, some key shortcuts for tab items are set in addition to above table.

Example of configuration

{
  "hot_key": "F8",
  "icon_color": "black",
  "always_on_top": false,
  "normal_window": false,
  "zoom_factor": 0.9,
  "chromium_sandbox": true,
  "accounts": [
    {
      "name": "Linda_pp",
      "host": "mstdn.jp",
      "default_page": "/web/timelines/home"
    },
    {
      "name": "inudog",
      "host": "mastodon.social",
      "default_page": "/web/timelines/home"
    }
  ],
  "keymaps": {
    "1": "/web/statuses/new",
    "2": "/web/timelines/home",
    "3": "/web/notifications",
    "4": "/web/timelines/public/local",
    "5": "/web/timelines/public",
    "6": "/web/getting-started",
    "ctrl+1": "/web/statuses/new",
    "ctrl+2": "/web/timelines/home",
    "ctrl+3": "/web/notifications",
    "ctrl+4": "/web/timelines/public/local",
    "ctrl+5": "/web/timelines/public",
    "ctrl+6": "/web/getting-started",
    "j": "scroll-down",
    "k": "scroll-up",
    "i": "scroll-top",
    "m": "scroll-bottom",
    "n": "next-account",
    "p": "prev-account"
  }
}

Multi account

If you add multiple accounts to the accounts array in config.json, an Accounts menu item will appear in the application menu.

multi account menu item

It will show the list of your accounts. The check mark indicates the current user. When you click menu item of non-current user, application window will be recreated and switch page to the account.

Key Shortcut Plugin

By specifying JavaScript file to action name in keymaps of config.json, you can write your favorite behavior with JavaScript directly. Please note that "chromium_sandbox" : true is also required (if you don't know what happens with "chromium_sandbox" : true, please read the above config section).

{
    ...

    "chromium_sandbox": false,

    ...

    "keymaps": {
        "r": "hello.js"
    }
}

The script file path is a relative path from your Mstdn application directory. For example, Specifying hello.js will run /Users/You/Application Support/Mstdn/hello.js on Mac.

The plugin script MUST export one function. The function receives a configuration object and the current account object as its parameters. So the above hello.js would look like:

module.exports = function (config, account) {
    alert('Hello, ' + account.name);
}

With above example config, typing r will show 'Hello, {your name}' alert dialog. You can use any DOM APIs, Node.js's standard libraries and Electron APIs in a plugin script.

User CSS

When user.css is put in your Mstdn application directory, it will be loaded automatically. To enable this feature, "chromium_sandbox" : true is also required (if you don't know what happens with "chromium_sandbox" : true, please read the above config section).

For example, the below /Users/You/Application Support/Mstdn/user.css will change font color to red on Mac.

body {
  color: red !important;
}

Plugin (experimental)

You can make a Node.js package which is run inner mastodon page.

Plugin is enabled if chromium_sandbox option is set to false. Please read above configuration section before using any plugin.

How to make a plugin

Create a node_modules directory in your application directory at first. And then, please make mstdn-plugin-hello directory. It consists a node package.

The package name must start with mastdn-plugin-.

Make package.json manually or by $ npm init in the directory.

{
  "name": "mstdn-plugin-hello",
  "version": "0.0.0",
  "description": "Sample plugin of Mstdn.app",
  "main": "index.js",
  "author": "Your name",
  "license": "Some license"
}

And make index.js as below:

module.exports = {
    preload(config, account) {
        console.log('Hello from plugin!', config, account);
    }
};

Each package must export one object. If the object has a function as a value of preload key, it will be called when the page is being loaded. The function receives two parameters config and account.

By defining keymaps key you can define plugin-defined key shortcut action.

module.exports = {
    preload(config, account) {
        console.log('Hello from plugin!', config, account);
    },
    keymaps: {
        'alert-hello'(event, config, account) {
            event.preventDefault();
            alert('Hello, ' + account.name);
        }
    }
};

The keymaps object has keymap action name (key) and its handler (value). Here 'alert-hello' key shortcut action is defined. Key shortcut handler takes 3 arguments. config and account is the same as preload's. event is a KeyboardEvent browser event on the key shortcut being called. You can cancel default event behavior using the .preventDefault() method.

User can specify the key shortcut as plugin:{plugin name}:{action name}. In above example, plugin:hello:alert-hello is available in keymaps section in config.json.

Note that you can use below APIs in the script.

!!! Security Notice !!!

Do not leak Node.js stuff to global namespace like below.

// Never do things like this!
window.my_require = require;

How to use

If you didn't try above 'How to make' section, please install plugin package at first. Below will install 'hello' plugin to {app directory}/node_modules/mstdn-plugin-hello.

$ cd {Your application directory}
$ npm install mstdn-plugin-hello

And then write what plugin should be loaded to "plugins" section of your account in config.json. "hello" should be added to the list. If listed plugin defines some keymaps, you can specify it in keymaps section with plugin:{name}:{action} format.

{
    ...

    "accounts": [
        {
            ...

            "plugins": [
                "hello"
            ]
        }
    ],
    "keymaps": {
        ...

        "ctrl+h": "plugin:hello:alert-hello"
    },

    ...
}

Note that you can enable different plugin for each your accounts.

Finally open Mstdn.app and open the DevTools via [Menu] -> [View] -> [Developper Tools] -> console. If window is too small to see DevTools, please make window size bigger.

In the developer console, the message 'Hello from plugin!', config information and account information should be output.

List of Plugins

To be made

How to Debug

By setting NODE_ENV environment variable to development, Mstdn will start in debug mode.

In debug mode, app outputs all logs to stdout and opens DevTools for a page rendered in a window automatically. You can also see logs in 'console' tab of DevTools for debugging renderer process.

# If you installed this app via npm or yarn
$ NODE_ENV=development open-mstdn-app

# Package on macOS
$ NODE_ENV=development /path/to/Mstdn.app/Contents/MacOS/Mstdn

# Package on Linux
$ NODE_ENV=development /path/to/Mstdn-linux-xxx-x.y.z/Mstdn

# Package on cmd.exe on Windows
$ set NODE_ENV=development
$ \path\to\Mstdn-win32-xxx-x.y.z\Mstdn.exe

Contact to the Author

Please feel free to create an issue on GitHub or mention me on Mastodon/Twitter.

More Repositories

1

vim.wasm

Vim editor ported to WebAssembly
Vim Script
5,305
star
2

actionlint

:octocat: Static checker for GitHub Actions workflow files
Go
2,605
star
3

NyaoVim

Web-enhanced Extensible Neovim Frontend
TypeScript
2,207
star
4

git-messenger.vim

Vim and Neovim plugin to reveal the commit messages under the cursor
Vim Script
1,263
star
5

vim-grammarous

A powerful grammar checker for Vim using LanguageTool.
Vim Script
1,058
star
6

vim-clang-format

Vim plugin for clang-format, a formatter for C, C++, Obj-C, Java, JavaScript, and so on.
Vim Script
1,036
star
7

clever-f.vim

Extended f, F, t and T key mappings for Vim.
Vim Script
968
star
8

Shiba

Rich markdown live preview app with linter
TypeScript
751
star
9

gocaml

🐫 Statically typed functional programming language implementation with Go and LLVM
Go
732
star
10

kiro-editor

A terminal UTF-8 text editor written in Rust πŸ“πŸ¦€
Rust
728
star
11

committia.vim

A Vim plugin for more pleasant editing on commit messages
Vim Script
687
star
12

go-github-selfupdate

Binary self-update mechanism for Go commands using GitHub
Go
527
star
13

conflict-marker.vim

Weapon to fight against conflicts in Vim.
Vim Script
442
star
14

wain

WebAssembly implementation from scratch in Safe Rust with zero dependencies
Rust
425
star
15

hgrep

Grep with human-friendly search results
Rust
419
star
16

electron-about-window

'About This App' mini-window for Electron apps
TypeScript
405
star
17

tui-textarea

Simple yet powerful multi-line text editor widget for ratatui and tui-rs
Rust
287
star
18

vim-color-spring-night

Low-contrast calm color scheme for Vim
Rust
276
star
19

cargo-husky

Setup Git hooks automatically for cargo projects with 🐢
Rust
260
star
20

dot-github

.github directory generator
Go
248
star
21

8cc.vim

C Compiler written in Vim script
Vim Script
227
star
22

vim-startuptime

A small Go program for better `vim --startuptime` alternative
Go
191
star
23

notes-cli

Small markdown note taking CLI app playing nicely with your favorite editor and other CLI tools
Go
191
star
24

dotfiles

dotfiles symbolic links management CLI
Go
191
star
25

neovim-component

<neovim-editor> WebComponent to embed Neovim to your app with great ease
TypeScript
188
star
26

reply.vim

REPLs play nicely with :terminal on Vim and Neovim
Vim Script
183
star
27

monolith-of-web

A chrome extension to make a single static HTML file of the web page using a WebAssembly port of monolith CLI
TypeScript
183
star
28

github-complete.vim

Vim input completion for GitHub
Vim Script
168
star
29

Trendy

Menubar app to keep you in the loop of GitHub trends :octocat:
TypeScript
166
star
30

git-brws

Command line tool to open repository, file, commit, diff, tag, pull request, blame, issue or project's website in browser for various repository hosting services.
Rust
166
star
31

devdocs.vim

Open devdocs.io from Vim
Vim Script
164
star
32

react-vimjs

Vim in Your Web App
JavaScript
158
star
33

vim-operator-surround

Vim operator mapping to enclose text objects with surrounds like paren, quote and so on.
Vim Script
137
star
34

react-vim-wasm

Vim editor embedded in your React web application
TypeScript
128
star
35

action-setup-vim

GitHub Action to setup Vim or Neovim on Linux, macOS and Windows for testing Vim plugins
TypeScript
126
star
36

accelerated-jk

A vim plugin to accelerate up-down moving!
Vim Script
125
star
37

dogfiles

dog + dotfiles = dogfiles
Vim Script
120
star
38

vim-gfm-syntax

GitHub Flavored Markdown syntax highlight extension for Vim
Vim Script
117
star
39

wandbox-vim

Wandbox plugin for vimmers. http://melpon.org/wandbox/
Vim Script
108
star
40

fixjson

JSON Fixer for Humans using (relaxed) JSON5
TypeScript
99
star
41

tinyjson

Simple JSON parser/generator for Rust
Rust
97
star
42

remark-emoji

Remark markdown transformer to replace :emoji: in text
JavaScript
93
star
43

YourFukurou

Hackable YoruFukurou alternative Twitter client
TypeScript
88
star
44

vim-lsp-ale

Bridge between vim-lsp and ALE
Vim Script
86
star
45

Dachs

Dachs; A Doggy 🐢 Programming Language
C++
81
star
46

vim-textobj-anyblock

A text object for any of '', "", (), {}, [] and <>.
Vim Script
79
star
47

vim-wasm

WebAssembly filetype support for Vim
Vim Script
77
star
48

world-map-gen

πŸ—ΊοΈRandom world map generator CLI and library for Rust and WebAssembly
Rust
74
star
49

vim-go-impl

A Vim plugin to use `impl` command
Vim Script
72
star
50

rust-doc.vim

Search Rust documents and open with browser from Vim.
Vim Script
71
star
51

ghci-color

colorize ghci output
PowerShell
71
star
52

electron-in-page-search

Module to introduce Electron's native in-page search avoiding pitfalls
TypeScript
66
star
53

translate-markdown

CLI tool to translate Markdown document with Google translate
JavaScript
66
star
54

tweet-app

Desktop Twitter client only for tweeting. Timeline never shows up.
TypeScript
65
star
55

dirname-filename-esm

__dirname and __filename for ES Modules environment
JavaScript
65
star
56

github-clone-all

Clone (~1000) repos matched to query on GitHub using Search API
Go
63
star
57

Tui

Twitter client based on mobile.twitter.com in menu bar
TypeScript
62
star
58

array_view

Wrapper for references to array in C++.
C++
58
star
59

vim-textobj-ruby

Make text objects with various ruby block structures.
Vim Script
56
star
60

fast-json-clone

Clone plain JSON value faster than the fastest
TypeScript
56
star
61

riscv32-cpu-chisel

Learning how to make RISC-V 32bit CPU with Chisel
Scala
55
star
62

changelog-from-release

Simple changelog generator via GitHub releases
Go
54
star
63

vim-llvm

Vim filetype support for LLVM (including official files)
Vim Script
49
star
64

Tilectron

Tiling window browser built on Electron.
JavaScript
45
star
65

nyaovim-markdown-preview

Live Markdown Preview on NyaoVim
HTML
45
star
66

Chromenu

Mobile Chrome in your menubar
TypeScript
43
star
67

Crisp

Lisp dialect implemented with Crystal
Crystal
43
star
68

path-slash

Tiny Rust library to convert a file path from/to slash path
Rust
41
star
69

open-pdf.vim

Convert pdf file to plain text, cache it and open it quickly in vim using pdftotext.
Vim Script
39
star
70

fixred

Fix outdated links in files with redirect URLs
Rust
35
star
71

ghpr-blame.vim

Vim plugin which is like `git-blame`, but for pull requests on GitHub
Vim Script
34
star
72

vim-healthcheck

Polyfill of Neovim's health-check for Vim
Vim Script
33
star
73

nyaovim-mini-browser

Embedded Mini Browser for NyaoVim
HTML
31
star
74

vim-color-splatoon

Vim Splatoon randomized color scheme. Let's play!
Vim Script
29
star
75

vim-fixjson

Vim plugin for fixjson; a JSON fixer for Humans
Vim Script
24
star
76

unite-redpen.vim

A unite.vim integration of redpen for automatic proof reading
Vim Script
24
star
77

vimwasm-try-plugin

Try Vim plugin on your browser without installing it using vim.wasm!
Go
24
star
78

react-component-octicons

Zero-dependency React component for Octicons
TypeScript
24
star
79

go-fakeio

Small Go library to fake stdout/stderr/stdin mainly for unit testing
Go
24
star
80

unite-codic.vim

A unite.vim source for codic-vim.
Vim Script
23
star
81

vim-goyacc

Vim filetype support for goyacc
Vim Script
22
star
82

gofmtrlx

(a bit) relaxed gofmt
Go
22
star
83

try-colorscheme.vim

Try colorscheme on your Vim without installation
Vim Script
21
star
84

node-github-trend

node.js library for scraping GitHub trending repositories.
TypeScript
20
star
85

node-github-emoji

Node.js library for GitHub Emoji :octocat: with TypeScript support
TypeScript
20
star
86

vim-syntax-christmas-tree

Vim filetype plugin for X'mas
Vim Script
20
star
87

toy-riscv-backend

Toy RISC-V LLVM backend
C++
18
star
88

FrozenString

C++ immutable string library in C++11 constexpr and type-level
C++
18
star
89

nyaovim-tree-view

Tree-view sidebar for NyaoVim
JavaScript
18
star
90

vim-github-actions

(Outdated) Vim syntax/indent support for GitHub Actions *.workflow files
Vim Script
18
star
91

zsh-bundle-exec

No longer need to type in 'bundle exec'.
Shell
17
star
92

locerr

❌ locerr (locational error): Library for nice-looking errors in source code
Go
16
star
93

rhysd

README.md for my profile page
Ruby
16
star
94

unite-ruby-require.vim

A unite.vim source for searching gems to require
Vim Script
15
star
95

vim-textobj-conflict

Vim text object plugin to select conflicts
Vim Script
15
star
96

electron-open-url

Open URL with Electron window from command line or Node.js program
JavaScript
15
star
97

vim-notes-cli

Vim plugin for notes-cli
Vim Script
15
star
98

marked-sanitizer-github

A sanitizer for marked.js which sanitizes HTML elements in markdown with the same manner as GitHub
TypeScript
14
star
99

api-dts

d.ts generator from JSON API response
Go
13
star
100

Irasutoyer

Desktop app for Irasutoya lovers
TypeScript
13
star