sindresorhus / xbar Goto Github PK
View Code? Open in Web Editor NEWSimplifies BitBar app plugin creation
License: MIT License
Simplifies BitBar app plugin creation
License: MIT License
I have been using the alfy package to develop some Alfred workflows.
Now I took a look at the xbar package you created and wondered if this could be improved to also make it possible to install xbar plugins via npm similar to the way this is handled with Alfred?
I already have some ideas but thought I might ask if this is something you are interested in building / integrating.
Cheers and Happy New Year π
Text shouldn't be mandatory in options. Currently there's a type error if text
is omitted.
According to the BitBar docs those options accepts a base64 encoded image. We could be nice and handle the encoding for the user so they could either specify a Buffer or a filepath to an image.
The docs says Applies to all items unless overridden in the item.
but it's the other way around according to the Object.assign. See code here
const actual = bitbar.create([
{
text: 'Default font'
},
{
text: 'Overriden font',
font: 'Comic Sans MS'
}
], {
font: 'Arial'
});
Expected Output:
Default font|font="Arial"
Overriden font|font="Comic Sans MS"
Actual Output:
Default font|font="Arial"
Overriden font|font="Arial"
I will create a PR.
I love that this exists and is updated for ESM and new node versions.
Is it up in the cards to move this package to the new xbar branding?
An item in a submenu is unable to have a submenu. Results in a TypeScript type error.
This is supported by Bitbar.
Hi Sindre,
This is a great api so thanks first of all for making it.
I went by the guide in the README but the JS example you provided seems to cause an issue whereby the β€and the 'Unicorns' object keep switching between each other on the menu bar. I've attached a gif below to better explain.
I've tried refreshing the plugins folder and restarting BitBar but neither of these seems to work.
Lines beginning with -- will appear in submenus, this is not currently supported here.
Note: It seems that bitbar supports up to 2 levels of submenus and separators don't work inside submenus.
If a URL passed to href
has special characters, such as single quotes, ampersands, etc., then the URL ends with that character when opened via this package to BitBar.
Per this, seems like the single quote has to be specifically escaped after the encodeURI
:
https://github.com/sindresorhus/bitbar/blob/4abea7e002a29fec7118af85119387a4530c7a76/index.js#L34
[
<
i
m
g
4
'
'
s
a
s
i
k
a
n
t
h
5
1
3
'
2
4
2
4
s
a
s
i
k
a
n
t
h
5
1
3
]
(
h
t
t
p
s
:
/
/
i
s
s
u
e
h
u
n
t
.
i
o
/
u
/
s
a
s
i
k
a
n
t
h
5
1
3
)
h
a
s
b
e
e
n
r
e
w
a
r
d
e
d
.
IssueHunt has been backed by the following sponsors. Become a sponsor
Ive setup my script with the following first two lines
#!/usr/bin/env ~/.nvm/versions/node/v16.9.1/bin/node --input-type=module
import xbar, { separator, isDarkMode } from "@sindresorhus/xbar";
....
Xbar displays the following
/Users/viperfx/Library/Application Support/xbar/plugins/xbar.js:2
import xbar, { separator, isDarkMode } from "@sindresorhus/xbar";
^^^^^^
SyntaxError: Cannot use import statement outside a module
Ive followed the readme as instructed - is there something else? PS - I installed the package with npm -g
I tried your demo and as per matryer/xbar#189, BitBar fails when there are unrecognized files/folders in its plugin directory.
How do you work around the issue?
I currently install the modules in a folder outside but that transforms every require into something like
require('../node_modules/bitbar')
Adding a separator just adds ---
at both the top-level menu and in submenus . In submenus, separators need to be prepended with the appropriate indentation of --
s.
See matryer/xbar#281
Thanks for creating this!
When I tried the example from the README, bitbar.darkMode
always returns true
. I have also tried performing a Refresh All without success. Any ideas?
macOS 10.14.4
BitBar 1.9.2
When it's out. Seems it has added a lot of new features since I last used it.
https://github.com/matryer/bitbar/releases
Help welcome :)
I have a similar project for PHP plugins https://github.com/SteveEdson/bitbar-php, would you like to link between the two, plus any other formatters in other languages?
No problem if not!
Separators aren't being allowed in submenus. Results in a Typescript type error.
This is supported in bitbar 1.9.2 (should be the same for xbar 2.x but haven't verified), and the js implementation already works correctly in sindresorhus/bitbar.
Example:
bitbar([
{ text: 'I<3bitbar' },
bitbar.separator,
{
text: 'submenu',
submenu: [
{ text: 'foo' },
bitbar.separator, // Type 'symbol' is not assignable to type 'string | Options'.
{ text: 'bar' }
]
}
]);
For the href option encodeURI is currently applied to the key and not the value.
Current:
if (x === 'href') { x = encodeURI(x); }
Expected
if (x === 'href') { x = encodeURI(line[x]); }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.