tonsky / anybar Goto Github PK
View Code? Open in Web Editor NEWOS X menubar status indicator
License: Eclipse Public License 1.0
OS X menubar status indicator
License: Eclipse Public License 1.0
I was wondering what font that @tonsky used in the screenshot.
This is only an issue with my rudimentary Swift skills – sorry if it's inappropriate to post here.
That said… any suggestions for how to change the icon in Swift? I've explored NSTask with both echo and via an AppleScript. Establishing a connection using BSD sockets seems like massive overkill (and I haven't been successful in any event.)
Hi,
I wrote an awfully simple C command line client for AnyBar:
The link for the C++ library is dead.
https://github.com/enedil/anybar-cpp
Fresh Homebrew reinstall, and I get a Finder dialog:
“AnyBar” can’t be opened because Apple cannot check it for malicious software.
This software needs to be updated. Contact the developer for more information.
Homebrew Cask downloaded this file on February 22, 2021 from github.com.
I run a launchd service which runs a bash script to update anybar status every 1m, and this will make anybar steal the window focus, which is very annoying.
How can I prevent this?
Not sure if this is a Yosemite only tool, but I'm getting the following on Mavericks.
$ open /Applications/AnyBar.app
LSOpenURLsWithRole() failed with error -10825 for the file /Applications/AnyBar.app.
i wrote an awfully simple node script for controlling the icon...
#!/usr/bin/env node
var dgram = require('dgram'),
anybarSocket = dgram.createSocket('udp4'),
message = new Buffer(process.argv[2]);
anybarSocket.send(
message,
0,
message.length,
process.argv[3] || 1738,
'localhost',
function() {
process.exit();
}
);
if you chmod +x scriptname
then you can ./scriptname question
or ./scriptname question 1234
.
i'm not sure if this is useful for anyone, but i got a little tired of doing echo -n "color" | nc blah blah
...
I've created a fork which adds support for any icons from icons8.com. Just pass a icon id and the icon will be used for the menu item.
Not sure whether you want this functionality in AnyBar or want to stick to the colored dots? Should I fine tune my fork and create a pull request?
Fork repo at https://github.com/niklasberglund/AnyBar-icons
i know in shell i can do echo -n black | nc -4u -w0 localhost <port number>
but i cant figure out how to accomplish this in applescript (besides using do shell script "command"
)
this would suggest its possible to set the udp port but i cant figure out the syntax.
Could it be possible to add a blinking function ? To catch the user's attention, by example.
Hi,
Would you mind adding a LICENSE
file to your project? Thanks!
I'm not going to put a full PR on this commit because I made some changes to default behavior, but if you're interested in gleaning/repurposing anything, let me know. I can revert the default changes and issue an actual PR if you'd like.
Short version:
set title
and set color name "none"
Fork is located here: https://github.com/ttscoff/AnyBar/
when I launch it, it uses old dot styles, rarely it uses new, but if I try fill and hollow on them which I wanted it doesn't work and goes back to previous version dots, is this version only for big sur?
launchd
has a functionality where it can bind to a socket, and when there's incoming traffic, it starts a service and passes that on. It should be usable by Anybar.
I'm not sure on the details. On Linux, systemd allows this, and I know they copied this design feature from macOS, and that's the extent of my familiarity on it. This link seems very useful. plist
is a keyword here.
With such a setup, AnyBar could be set up to start automatically when an application attempts to connect to it, without requiring any change on client's side.
I would absolutely love to create some plugins for my automated tasks so I don't have to tab to them, any chance you could publish this to Homebrew? https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md#formula-cookbook
Similar to ttscoff's previous issue, I'm not making this a PR because my changes break compatibility with OS X 10.9. But I wanted to put this here in case it would be useful. Perhaps someday 10.9 compatibility won't be a requirement and these changes can be pulled?
I've made some changes to AnyBar to add
Template
So you can do something like this:
echo -n "#ffcc33 Hello World" | nc -4u -w0 localhost 1738
Here is the fork: https://github.com/sfsam/AnyBar
It would be nice if we could also send some arbitrary message to Anybar, which would be revealed in the pop-up menu by clicking on the icon.
Optionally, there could be a badge on Anybar to indicate that there's a new message to be read.
I created a small golang app to help manage anybar. Hope this is helpful
I published static binaries for OSX and Linux here but anyone should be able to build it themselves as long as they have go installed.
By replying back. I want to ensure the status was changed successfully. Could be useful to also include in the reply whether the sent command was valid.
The main README page includes a link which displays as https://github.com/raguay/MyAlfred but actually links to https://github.com/raguay/MyAlfred/blob/master/AnyBarWorkflow.alfredworkflow.
That link is 404.
However, there is a new link:
https://github.com/raguay/MyAlfred/blob/master/Alfred%204/AnyBar%20Workflow.alfredworkflow
which I believe is the same thing but apparently raguay
reorganized their repo.
If you link to
https://github.com/raguay/MyAlfred/raw/master/Alfred%204/AnyBar%20Workflow.alfredworkflow
it should offer to download it directly.
Hi, I couldn't run the nc
command as expected.
It seems I have a different version of netcat.
I am using macOS Sierra 10.12.5
$ echo -n "black" | nc -4u -w0 localhost 1738
nc: invalid option -- 4
Try `nc --help' for more information.
$ nc --version
netcat (The GNU Netcat) 0.7.1
Copyright (C) 2002 - 2003 Giovanni Giacobbi
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program under the terms of
the GNU General Public License.
For more information about these matters, see the file named COPYING.
Original idea and design by Avian Research <[email protected]>,
Written by Giovanni Giacobbi <[email protected]>.
$ nc --help
GNU netcat 0.7.1, a rewrite of the famous networking tool.
Basic usages:
connect to somewhere: nc [options] hostname port [port] ...
listen for inbound: nc -l -p port [options] [hostname] [port] ...
tunnel to somewhere: nc -L hostname:port -p port [options]
Mandatory arguments to long options are mandatory for short options too.
Options:
-c, --close close connection on EOF from stdin
-e, --exec=PROGRAM program to exec after connect
-g, --gateway=LIST source-routing hop point[s], up to 8
-G, --pointer=NUM source-routing pointer: 4, 8, 12, ...
-h, --help display this help and exit
-i, --interval=SECS delay interval for lines sent, ports scanned
-l, --listen listen mode, for inbound connects
-L, --tunnel=ADDRESS:PORT forward local port to remote address
-n, --dont-resolve numeric-only IP addresses, no DNS
-o, --output=FILE output hexdump traffic to FILE (implies -x)
-p, --local-port=NUM local port number
-r, --randomize randomize local and remote ports
-s, --source=ADDRESS local source address (ip or hostname)
-t, --tcp TCP mode (default)
-T, --telnet answer using TELNET negotiation
-u, --udp UDP mode
-v, --verbose verbose (use twice to be more verbose)
-V, --version output version information and exit
-x, --hexdump hexdump incoming and outgoing traffic
-w, --wait=SECS timeout for connects and final net reads
-z, --zero zero-I/O mode (used for scanning)
Remote port number can also be specified as range. Example: '1-1024'
The XDG Base Directory Specification provides a bunch of folders for collating config files, and mechanisms to override the default (~/.config
), so our home folders don't end up stuffed with dot files.
It would be great if AnyBar could support .config/AnyBar
in addition to .AnyBar
.
I really like AnyBar, good job 👍
One thing I would love to see though would be a way to set the initial color of the dot. Maybe there is even already something like this implemented?
Asking because calling open -na Anybar && echo -n "green" | nc -4u -w0 localhost 1738
does not set the color of the dot to green, I think because open
in itself operates in the background.
One could insert a sleep 0.5s
like this: open -na Anybar && sleep 0.5s && echo -n "green" | nc -4u -w0 localhost 1738
but it flickers the dot color because it is set to white initially.
I think something like ANYBAR_INITIAL_COLOR
would be amazing!
There is a new Rust client for AnyBar:
https://github.com/Feliix42/anybar-rs
Regards.
So how come my anybar dot reverts to red after blinking momentarily into the desired colour for a second or two? very frustrating. however this problem fixes itself once i disconnect/reconnect my wifi. please help.
I tried to get combination of netcat parameters to send out single command and terminate, but failed. The command sits open till you ^C it.
Could you please provide modern working example in documentation?
$ /bin/bash
bash-3.2$ echo -n "black" | nc -4u -w0 localhost 1738
nc: invalid option -- 4
Try `nc --help' for more information.
bash-3.2$ echo -n "black" | nc -u -w0 localhost 1738
Error: Invalid wait-time: 0
bash-3.2$ echo -n "black" | nc -u -w 1 localhost 1738
^C
Which version is being used:
bash-3.2$ ls -l `which nc`
/usr/local/bin/nc -> ../Cellar/netcat/0.7.1/bin/nc
bash-3.2$ brew info netcat
netcat: stable 0.7.1
Utility for managing network connections
http://netcat.sourceforge.net/
/usr/local/Cellar/netcat/0.7.1 (10 files, 103.3K) *
Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/netcat.rb
bash-3.2$
Please, add extension for ipython based on AnyBar in description README.md
https://github.com/ermakovpetr/ipython-anybar
how would you set a custom image using applescript?
i would be comfortable doing it from terminal also but try to just change the color from terminal with echo -n "black" nc -4u -w0 localhost 1738
changes it for instant (ala issue #45)
EDIT: i figured out why it was reverting back for me when using bash. i was running a looping applescript to show the playing state of spotify and it was still running. oops
echo -n "<color>" | nc -4u -w0 localhost 1738
stopped working on my system (macOS 10.14.6). Getting the error message nc: getaddrinfo: nodename nor servname provided, or not known
. This happens with both shell scripts and manual execution.
With AppleScript it's still working, i.e. osascript -e 'tell application "AnyBar" to set image name to "<color>"'
Anyone know what the problem could be?
PS (edit): adding /usr/bin/nc to the Accessibility list doesn't help.
So, in the demo image, there's an icon of communism on the developer's menubar. I'd love to know what app that is.
When I try to use anybar from a shell script, I can't seem to get it to change the icon to anything but "question". I'm sure that it's something I'm doing wrong. It is actually changing the icon, but it's like the colour isn't getting sent through properly? I've tried using single quotes, escaping the quotes -- what am I doing wrong?
#!/bin/sh
echo -n "black" | nc -4u -w0 localhost 1738
When I use anybar green
, I get:
$ anybar green
-bash: anybar: command not found
So what's the bash alias for anybar?
Thanks for making this. I'm using AnyBar to show the status of some of my Hammerspoon functions [Lua for mac automation], but I'm having trouble identifying when AnyBar is open or closed. I end up launching duplicate processes or not having a process open. How does everyone else deal with those issues?
But in trying to write my question I think I found a couple of ways to solve this:
# A port known to be open returns a line of text
$ sudo nmap -sU -p 1740 $(ipconfig getifaddr en0) | grep open
1740/udp *open*|filtered encore
# While a closed port returns no text
$ sudo nmap -sU -p 9999 $(ipconfig getifaddr en0) | grep open
But this method can be prone to false positives. Alternatively, I launch a set number of AnyBar icons, so I can make sure they are open by counting the number of lines returned from the process list (the [ ] idea was from stackoverflow):
$ ps aux | grep -i '[a]nybar'
kyleking 9728 0.0 0.1 2579936 13844 ?? S 10:54AM 0:00.15 /opt/homebrew-cask/Caskroom/anybar/0.1.3/AnyBar.app/Contents/MacOS/AnyBar
kyleking 9726 0.0 0.1 2579936 14020 ?? S 10:54AM 0:00.16 /opt/homebrew-cask/Caskroom/anybar/0.1.3/AnyBar.app/Contents/MacOS/AnyBar
kyleking 9567 0.0 0.1 2579936 14220 ?? S 10:51AM 0:00.33 /opt/homebrew-cask/Caskroom/anybar/0.1.3/AnyBar.app/Contents/MacOS/AnyBar
Then to quit the app from a shell prompt, I'm just using:
sudo kill $(ps aux | grep -i '[a]nybar' | awk '{print $2}')
Is there a way to build something like this in Applescript or built-in to AnyBar?
First, let me say I'm excited to have found this wonderful little app that is so simple to use and so versatile! I am currently using it warn when I have disabled sleep mode on my MBP, however, I would like it to be even more obvious than the exclamation
sitting motionless in the bar...
It would be awesome if there was a flash
parameter... just a simple blink on and off at 1-second intervals. Even better if there was a way to customize the flashing interval, etc.
I would try to submit a pull for this feature but that type of coding is above my helmet. For now, I'm going to try and hack the feature by having a Keyboard Maestro macro that uses the nc
calls to flash it on and off.
Thanks for listening! Keep up the great work!
Hi, I made an Alfred client you might want to add to the page: https://github.com/raguay/MyAlfred/blob/master/AnyBarWorkflow.alfredworkflow
My Hammerspoon workflow in the same repository uses it to show the caffeinate status.
This might be out of scope of this app, but it would be useful to be able to set a tooltip for the menubar app, from a client. This is especially useful when you have multiple instances of AnyBar so you can distinguish them.
Some icons can be rearranged by command+click/drag. Please implement this feature so I can easily keep my menubar organised without having to buy bartender.
I'm seeing this in 10.12 beta, but I'm guessing that this might be happening in 10.11 too:
When running in dark mode (System Prefs > General > Use dark menu bar and Dock), this creates a white dot:
$ echo -n "black" | nc -4u -w0 localhost 1738
This is minor, arguably correct, but potentially misleading? Not sure if there's a better way here.
The executable in AnyBar-0.2.0.zip has version number 0.1.4
Is it the correct executable with a wrong version number? Or the wrong executable?
It would be awesome if it is possible to play some sound every time it changes.
This means that choosing the image style based on whether dark mode is enabled or not is not sufficient to choose the correct image, as the menu bar may be using black icons or white icons regardless. This is a screenshot of my mac with dark mode enabled, but a light desktop background image, and setting anybar to the "black" image:
My desktop image is a dynamic wallpaper, so in the evening it's much darker and the mac switches to using white icons.
Can I place emoji (Unicode symbol) to menubar?
mv secret_icon.png ~/secret_icon.png
echo -n "../secret_icon" | nc -u localhost 1738
What should happen:
A question mark icon is displayed as no valid icon was found in ~/.AnyBar
What happens:
The secret icon is displayed which is located at ~/.AnyBar/../secret_icon.png
I can't think of a way to exploit it however.
What App is the Soviet Hammer and Sickle Icon in your menu bar? I'm so curious.
The method provided in the AnyBar README, using nc, has limitations when the process feeding nc's stdin is a little tardy: with the -w0
argument, nc will not wait for input and may exit prematurely.
For example, this silently doesn't work:
( sleep 1; echo -n "black" ) | nc -4u -w0 localhost 1738
A workaround would be to use some arbitrarily high value for the wait argument, but fundamentally nc doesn't provide a means to associate stdin closing and closing the UDP "connection" (put another way, it doesn't have a "write only" mode). (at least one implementation of nc does provide a -c
option that will wait for stdin to close, but it's not common)
BASH provides a very useful network redirection feature, this avoids the issue and also has fewer (zero!) dependancies:
( sleep 1; echo -n "black" ) > /dev/udp/localhost/1738
Suggest replacing the examples in the README with the BASH invocations.
I have a scenario where it can happen that some code launches AnyBar on the same port in quick succession which leads to warning icons displayed in the menu bar:
ANYBAR_PORT=1740 ANYBAR_INIT=green open -n /Applications/AnyBar.app
Is it possible to change this, maybe via a new environment variable, to just exit AnyBar silently without displaying the warning?
Those unfamiliar with Homebrew-cask will likely enter the commands you provide and expect a result. Per the README, I typed brew cask install anybar
then proceeded to the Usage section, entering echo -n "black" | nc -4u -w0 localhost 1738
. No icon appeared in my menubar. I checked my Applications directory as linked in the left pane of Finder windows and there is nothing named Anybar
. A casual user may give up.
Reading the directions provided by Homebrew-cask, I found that the .app was installed in /Users/myusername/Applications/. This can also be found via Spotlight (with the default configuration in OS X 10.10.2) yet the README does not provide any direction on how to launch the app before the Usage instructions can be utilized.
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.