News for hackers. Stuff that matters.
Re:Show HN: Universal Pause Button by tomkinstinch on Tuesday June 09, 2015 @02:08PM (#9687529)
This is nice! On OSX, processes can be paused and continued too (by name via killall, and by PID via kill):

  kill -STOP 1234
  kill -CONT 1234

  killall -STOP -c "Pandora"
  killall -CONT -c "Pandora"
A more nuanced control is to throttle down the CPU, via cputhrottle[1].

If I'm running a CPU-intensive calculation and don't want to bog down the rest of my system I will use it to give me enough cycles for Sublime Text to work smoothly.

It's easy to call:

  sudo cputhrottle PID cpuUsage%
ex.

  sudo cputhrottle 12345 400
1. http://www.willnolan.com/cputhrottle/cputhrottle.html
Re:Show HN: Universal Pause Button by rsync on Tuesday June 09, 2015 @03:41PM (#9688096)
"This is nice! On OSX, processes can be paused and continued too"

Every once in a while I am reminded how wonderful, and perhaps unlikely, it is that I have a nice, slick, mass market consumer device (apple computer running OS X) that is honest to god UNIX underneath.

And then sad, knowing that this is a brief golden age that will probably pass.

Re:Show HN: Universal Pause Button by bbcbasic on Tuesday June 09, 2015 @04:55PM (#9688485)
Don't worry. Linux is slicker.
Re:Show HN: Universal Pause Button by vonklaus on Tuesday June 09, 2015 @06:29PM (#9688924)
As someone who just switched to Linux from OS X, it is really hard to migrate. I miss the subtleties of the apple ecosystem. Sure Linux is awesome, but I have been battling trackpad support issues, keymapping the super_key to CMD, and just general battling the UX.

tl;dr a more powerful operating system with worse UI, which is the obvious trade. A less powerful system with a fantastic UI.

Re:Show HN: Universal Pause Button by wjoe on Wednesday June 10, 2015 @08:26AM (#9691538)
As someone who uses Linux for everything but just had to start using OS X for work, it's really hard to migrate. Remapping ctrl to cmd and various other keyboard oddities, unfamiliar mouse acceleration, and missing features like middle click to paste and holding alt to drag windows. Various other things that I'm able to customise to my liking in Linux, but are much harder to modify in OS X.

Chances are you're going to think that the thing you've been using for years is "good UI", and anything different is "bad UI". I don't doubt that Apple have spent a lot of time designing their UI/UX to work well for most people, but it feels bad to me because it's not what I'm used to.

Either way, you get used to it. I've found programs that make OS X work in a way that's more familar to me, and learned to work with the things I can't change.

Re:Show HN: Universal Pause Button by dripton on Tuesday June 09, 2015 @08:04PM (#9689332)
UI is subjective. I get mildly annoyed whenever I use a Mac. Little things like having to click on a window to give it focus, or having to use command instead of control in many programs, break my flow. I'd probably get used to those if I only used a Mac, but since I use Linux 95% of the time and Mac 5%, I never do.
Re:Show HN: Universal Pause Button by globuous on Wednesday June 10, 2015 @07:56AM (#9691367)
Honestly, i don't mind the window focusing on mac. What I absolutely fucking hate though, is working on Windows and not being able to scroll on a window that's not active. By default on Mac, if a window's focused, you can scroll another (unfocused) window by scrolling when you mouse is over it. Without having to refocus windows, which is really nice when you're typing something on the focused window.

As for the cmd button replacing the ctrl button. Never going back to ctrl+<key> for shortcuts. The command button is so much nicer to use, it's your thumb vs you pinky. You don't need to stretch you pinky/move you hand slightly to have access to shortcuts and that's so nice. VERY desturbing at first (I hated it), but never going back. Or maybe I've just gotten used to using my thumb. Ultimately, I think it makes a lot more sense though. No more alt-F4 to close windows, its cmd+Q, no more ctrl+B to bold a text, it's cmd+b, cmd+h minimizes/hides your window etc etc.

Also, what i found infinitely annoying at first and that I really like now on Mac, is the window switching with the keyboard. On Windows, alt+tab switches between all windows (including different instances of same program). on Mac, alt+tab switches between applications and alt+` switches between different instances of a said program. I find that more elegant when you have a lot of windows opened, which i always have.

But all these are tiny little things that add up to something really nice to use, but each individually don't and will never justify OS X being the best OS in the world blah blah. You can probably achieve a similar behavior on windows/Linux/whatever. What's nice about it though is that it's the default setup, no third party app needed/config files. You install it and it makes sense. That's why I'm not switching from OS X anytime soon, it's ergonomic, the UI is sick, power user features everywhere, and a real unix. I see it as a linux that works perfectly out of the box. I remember the first month I spent on OS X (coming from 4 years of linux, 2 yr Ubuntu and 2 yr Arch, using both full desktop env (KDE mostly) and lightweigth window managers), everything works and works well and everything is ergonomic and makes sense. Put simply, a Mac never (or very rarely) gets in the way of your work. And that makes a big difference.

But then, I just like Macs because of how I use my computer. I get it that some might prefer a Linux or Windows, and I respect that. I'm just extremely thankful OS X answers exactly what I expect from a computer.

Re:Show HN: Universal Pause Button by e_proxus on Wednesday June 10, 2015 @10:18AM (#9692354)
For Windows, Katmouse alleviates some of the pain of scroll focus: http://ehiti.de/katmouse/
Re:Show HN: Universal Pause Button by fastball on Tuesday June 09, 2015 @10:32PM (#9689738)
Wait how else do you give windows focus?

You mean like with the keyboard? Like SHIFT+TAB? That's on OS X.

Re:Show HN: Universal Pause Button by mouhtasi on Tuesday June 09, 2015 @10:35PM (#9689752)
I believe some window managers give the option of automatically focusing to the window under the cursor.
Re:Show HN: Universal Pause Button by endgame on Tuesday June 09, 2015 @10:58PM (#9689823)
And once you're used to it you'll never want to go back. All of my experiences with focus-follow-mouse on commercial OSes have been almost-but-not-quite right.
Re:Show HN: Universal Pause Button by eropple on Wednesday June 10, 2015 @01:28AM (#9690244)
> And once you're used to it you'll never want to go back.

Eh. I've used focus-follows-mouse and tend instead to strongly prefer the OS X method of allowing scroll events to percolate to the window under the cursor but retaining keyboard focus on the window it's currently in. This allows me to scroll, say, a web browser on my right-hand monitor, while continuing to type in the left.

Re:Show HN: Universal Pause Button by tehwalrus on Wednesday June 10, 2015 @03:52AM (#9690580)
Hover-focus is great on tiling window managers, but I'm not sure I'd react well to it where windows overlap by design.

Also, don't forget that OS X lets you scroll whatever window your mouse is over, even if it is "blurred" (not in focus). This is the one feature that I miss most whenever I need to use Windows.

Re:Show HN: Universal Pause Button by chimprich on Wednesday June 10, 2015 @04:23AM (#9690660)
There's a couple of free Windows programs that compensate for this. http://superuser.com/questions/110700/making-a-mouse-scroll-...
Re:Show HN: Universal Pause Button by 7Z7 on Wednesday June 10, 2015 @07:14AM (#9691197)
I, and many of the thousand or so Linux users at my company, disagree!

The only people here who really seem to like it are the ones using drawing-tablets as their main input.

Re:Show HN: Universal Pause Button by bubblesorting on Tuesday June 09, 2015 @11:36PM (#9689912)
Focus-follows-mouse doesn't work so great in OSX because of the global menubar, everywhere else it's great though!
Re:Show HN: Universal Pause Button by aerique on Tuesday June 09, 2015 @06:38PM (#9688985)
It's a phase. I run into similar issues when using OSX while being used to Linux.
Re:Show HN: Universal Pause Button by xur17 on Tuesday June 09, 2015 @07:24PM (#9689178)
I went through a similar struggle when switching to a Mac about a year ago for work. I still miss the ability to drag windows around from anywhere by holding the alt key, and dragging any part of the window.

Never found a good replacement in OSX.

Re:Show HN: Universal Pause Button by donut2d on Tuesday June 09, 2015 @11:43PM (#9689932)
You can do the same non-focused window dragging in OSX by holding down command. Actually, you can interact with the unfocused window when holding down command, click buttons, etc.
Re:Show HN: Universal Pause Button by geon on Wednesday June 10, 2015 @12:30AM (#9690047)
Dragging overlapping windows is a stupid idea to begin with. I use a keyboard based window manager as much as possible (Spectacle), and with splitscreen I can hopefully almost completely stop using windows.
Re:Show HN: Universal Pause Button by yoz-y on Wednesday June 10, 2015 @01:52AM (#9690310)
Overlapping windows is what makes mouse based interaction fast. Not everybody wants to use keyboard all the time. Also, often times it is useful to have more than two windows on screen at a time.
Re:Show HN: Universal Pause Button by geon on Wednesday June 10, 2015 @07:45AM (#9691320)
> Overlapping windows is what makes mouse based interaction fast.

How does the overlappingness make anything faster? If anything it becomes slower, because you need to move windows out of the way, or select them before you can get to the covered part.

> Not everybody wants to use keyboard all the time

In no way necessary. I don't think the WWDC splitscreen demo used keyboard shortcuts at all?

> it is useful to have more than two windows on screen at a time.

Having more than one window on the screen is also not helped by the windows overlapping. I regularly have 2-4 windows side-by-side on the same screen at once without overlapping, and multiple such screens and fullscreen windows on virtual desktops.

Re:Show HN: Universal Pause Button by wjoe on Wednesday June 10, 2015 @08:12AM (#9691444)
I use HyperDock for this: http://hyperdock.bahoom.com/

It's mainly focused on modifications for the OS X dock which I don't use, but it also does alt drag window movement, and alt + num pad for tiling windows. It costs a a bit of money after a trial period, but it's the most reliable replacement for alt drag I've found so far.

Re:Show HN: Universal Pause Button by vonklaus on Tuesday June 09, 2015 @07:56PM (#9689309)
haha. You guys must be right. That is the exact functionality that is the most annoying for me right now! I need to get used to this new OS. I miss 3 finger swipe right. ctrl+alt+shift+ [direction] is quite a macro just to move a screen.
Re:Show HN: Universal Pause Button by aerique on Wednesday June 10, 2015 @08:52AM (#9691699)
Realize that what you mean with "to get used to this new OS" is possibly "I need to get used to this desktop environment / window manager". I don't know what desktop environment you use but it is possibly Ubuntu's Unity, Gnome or KDE.

On Unix you have a lot of choice on the (graphical) interface you chose to interact with. So while to one you're currently using might be OK, there's bound to be one that's even better suited to your needs.

https://en.wikipedia.org/wiki/Window_manager

https://en.wikipedia.org/wiki/Desktop_environment

(Also, it's usually trivial to change your keybindings.)

Re:Show HN: Universal Pause Button by vonklaus on Wednesday June 10, 2015 @12:00PM (#9693169)
yep thanks. I run ParrotOS which is basically debian with some slick UI and pentesting toolsets. It is a gnome desktop enviro. I will check those links out. The keybindings did not hold on the tut I followed, no biggie. My major point is that I am a mac superuser, but when I switch windows I have to manually deselect a window (because it follows me). It is just absorbing the nuances of linux and inculcating the macros into my head.

It is like switching from JS to Ruby for me.

Re:Show HN: Universal Pause Button by girvo on Tuesday June 09, 2015 @09:07PM (#9689501)
I personally changed that to be Super+<Arrow> to change virtual desktop, and Super+Shift+<Arrow> to move the focused window to it. Much nicer shortcut, IMO. Elementary OS[0] uses that by default, actually.

[0] https://elementary.io/

Re:Show HN: Universal Pause Button by PhasmaFelis on Tuesday June 09, 2015 @08:51PM (#9689460)
Linux is a lot of good things, but "slicker than OS X" (in the sense of basic user-friendliness to the average computer user) is not really one of them.
Re:Show HN: Universal Pause Button by arthurcolle on Tuesday June 09, 2015 @03:56PM (#9688177)
Don't say that... why would Apple change the underlyings of OS X? Blasphemy :(
Re:Show HN: Universal Pause Button by schiffern on Tuesday June 09, 2015 @05:02PM (#9688516)
The precedent is already set. iOS is underlain by the same components, but the end user has no access.

We have also seen an incremental approach in the gradual replacement of open APIs/components with closed ones.

Re:Show HN: Universal Pause Button by tadfisher on Tuesday June 09, 2015 @05:18PM (#9688606)
They will when it conflicts with their business model. Witness protected access to media keys and the Notification Center.
Re:Show HN: Universal Pause Button by cookiecaper on Tuesday June 09, 2015 @05:00PM (#9688509)
Many would argue the golden age of OS X and nix compatibility has already passed. The last time I seriously used OS X was 10.4, but every release I hear about another set of nix compatibilities getting chipped away.
Re:Show HN: Universal Pause Button by crucini on Tuesday June 09, 2015 @08:18PM (#9689371)
Could you give some examples please?
Re:Show HN: Universal Pause Button by Dewie3 on Tuesday June 09, 2015 @05:53PM (#9688771)
> New operating systems today tend to be just ways of reimplementing Unix. If they have a novel architecture -- and some do -- the first thing to build is the Unix emulation layer.

> How can operating systems research be relevant when the resulting operating systems are all indistinguishable?

> There was a claim in the late 1970s and early 1980s that Unix had killed operating systems research because no one would try anything else. At the time, I didn’t believe it. Today, I grudgingly accept that the claim may be true (Microsoft notwithstanding).

> A victim of its own success: portability led to ubiquity. That meant architecture didn’t matter, so now there’s only one. Linux is the hot new thing... but it’s just another Unix.

http://herpolhode.com/rob/utah2000.pdf

Re:Show HN: Universal Pause Button by iwalton3 on Tuesday June 09, 2015 @10:01PM (#9689617)
Here is a quick clone of this project for Linux using the STOP and CONT signals:

  #!/bin/bash
  
  currentProcess=$(xprop -id $(xprop -root | grep -F '_NET_ACTIVE_WINDOW(WINDOW)' | awk '{print $5}') | grep -F '_NET_WM_PID(CARDINAL)' | awk '{print $3}')
  
  state=$(grep 'State:' /proc/$currentProcess/status | awk '{print $2}')
  
  if [[ "$state" == "T" ]]
  then
      kill -CONT $currentProcess
  else
      kill -STOP $currentProcess
  fi
Re:Show HN: Universal Pause Button by vezzy-fnord on Tuesday June 09, 2015 @03:06PM (#9687914)
SIGSTOP and SIGCONT are generic Unix signals.

Where it gets more interesting is using elaborate checkpoint/restore [1] mechanisms for processes to serialize their state (open fds, watches, IPC, etc.) into an image that can then be overlayed, remotely executed, debugged and so forth.

[1] https://en.wikipedia.org/wiki/Application_checkpointing

Re:Show HN: Universal Pause Button by derefr on Tuesday June 09, 2015 @04:50PM (#9688459)
I've always thought this was a wrongheaded solution.

I mean, of course, we have these apps that splay themselves all over global system resources in complex ways, and so we need to track down how they've done that, record it, and then replay it later to restore them. It's necessary.

But imagine a well-behaved classical X11 app, running in something like a VM or Docker container. You execute its launcher, the VM spins up in the background, the app launches in the VM, and the app's X11 client connects to the X11 server you're staring at and displays things.

If we truly want to sandbox apps, wouldn't it make more sense to move more toward a model like that—one where you have a discrete "application backend process" running in a sandbox, and you can just chuck around the sandbox itself willy-nilly (freezing it, thawing it, copying it, etc.) because it has well-defined connection-points to the host?

Re:Show HN: Universal Pause Button by vezzy-fnord on Tuesday June 09, 2015 @05:35PM (#9688698)
The purpose of C/R isn't sandboxing, it has nothing to do with it. It's about managing internal state and data structures from an external agent.

C/R enables complete persistence by duplicating a process from its image, which can cut initialization and startup times by orders of magnitude, and resume service from an exact position with zero downtime, and not just basic mechanisms like socket superservers.

It lets you back up process state at any arbitrary moment, send it over the network, recalculate and reexec immediately and then thaw again for debugging it from that particular point.

It just helps enable live migrations and zero downtime recoordinations with far less complicated redundancy schemes. This includes containers. On top of it being a universal save/pause button.

Depending on the robustness of the image format, it can be made space efficient through deduplication.

C/R is quite invaluable for any scenario that involves fault tolerance, high response times, tracking down difficult bugs, low startup overhead and so on. I'm surprised why it's still such an obscure technique.

Besides, I don't think the primary use case here is even graphical apps (not that they don't work just fine). What you really want is a local indexed copy of all the execution environment details, like pipes, sockets, timers, ttys, timers, sigmasks, *fds, etc. for infrastructure.

Re:Show HN: Universal Pause Button by dx211 on Tuesday June 09, 2015 @06:31PM (#9688935)
OK, PowerShell magic time:

  calc
  $a = Get-Process calc
  $a.ProcessorAffinity = 1
  $a.PriorityClass = "Idle"
  $b = [Diagnostics.Process]::Start("PowerShell", "-c while (1) {}")
  $b.ProcessorAffinity = 1
Ta-da!
Re:Show HN: Universal Pause Button by archagon on Tuesday June 09, 2015 @02:18PM (#9687614)
I actually wrote a little GUI app to do this for me a while back! It works but the UI is a bit broken. Maybe somebody will find it useful.

https://github.com/archagon/app-pauser

Re:Show HN: Universal Pause Button by ars on Tuesday June 09, 2015 @02:29PM (#9687693)
On debian the program is cpulimit.
Re:Show HN: Universal Pause Button by leni536 on Tuesday June 09, 2015 @04:42PM (#9688418)
I think using nice or renice is better practice. Hard throttling is way more inefficient.
Re:Show HN: Universal Pause Button by curun1r on Tuesday June 09, 2015 @06:06PM (#9688824)
It may be, but it doesn't solve some of the problems that cputhrottle does. My main use for cputhrottle is to limit the CPU usage of Flash. It's not that I want to use the CPU for something else, at least not at the moment, but I don't want my laptop's fans to turn on, the whole thing to heat up and it to kill my battery life. [re]nice will only allow another process to get CPU priority, it won't keep the CPU utilization low.

The bizarre part, when it comes to Flash, is that I've yet to see an actual difference in the application behavior when I throttle down it's CPU usage. I would think that if it normally maxes out 7 of my 8 logical cores, being limited to 40% of one core would make introduce slowness. But I guess that's just an indication of how poorly written the OS X flash client it.

Re:Show HN: Universal Pause Button by dx211 on Tuesday June 09, 2015 @06:41PM (#9688998)
You might not notice the difference, but that guy at Apple who's only getting 5% of his usual haul of bitcoins this month sure will!
Re:Show HN: Universal Pause Button by tehwalrus on Wednesday June 10, 2015 @03:57AM (#9690590)
Flash is running an event engine like JS under there. Your comment made it occur to me that they might busywait, rather than having a proper scheduler. This seems insanely lazy.
Re:Show HN: Universal Pause Button by ars on Wednesday June 10, 2015 @03:45PM (#9694784)
It's not a busywait, they use the extra CPU to render additional animation frames. But half the time the difference is not visible anyway.
Re:Show HN: Universal Pause Button by anom9999 on Wednesday June 10, 2015 @03:51AM (#9690579)
Only yesterday I was raging at Flash for continually chewing up my CPU and RAM. I hadn't even considered setting limits on the processes. So thank you for the suggestion.
Re:Show HN: Universal Pause Button by ars on Tuesday June 09, 2015 @07:33PM (#9689216)
Nice solves a different problem: Making sure that less important programs don't hog cpu time.

I use cpulimit to force a CPU bound program to slow down. I also use it for programs that always max out the CPU for no good reason, and work fine with less CPU.

Nice won't help with either of those.

Re:Show HN: Universal Pause Button by jokr004 on Tuesday June 09, 2015 @03:09PM (#9687937)
The kill -STOP command works on linux too
Re:Show HN: Universal Pause Button by ars on Tuesday June 09, 2015 @03:15PM (#9687966)
It does, but cpulimit repeatedly stops/continues the program to keep it within a certain amount of CPU.

It works pretty good, but I have had flash games crash if you limit them too low for a while.

Re:Show HN: Universal Pause Button by jokr004 on Tuesday June 09, 2015 @03:58PM (#9688189)
Ok I had a total brain-fart there.. I didn't realize that you were responding about the cputhrottle command. Whoops