Tuesday, January 4, 2022

Recent Questions - Ask Different

Recent Questions - Ask Different


Can't test whether key exists in associative zsh array

Posted: 04 Jan 2022 03:24 AM PST

This is my script (zsh 5.8):

# Consider parameter expansion of an unset variable to be an error  set -u      # Define and populate associative array  typeset -A arr   arr=(x xxx y yyy)    echo $arr[x] # Outputs xxx    # Test whether key x is present  ((${arr[(Ie)x]})) && echo true  

The last line gives me the error zsh: x: parameter not set, and from this message I conclude that zsh treats the x not literally, but as a variable which zsh wants to expand. Why do I have a variable expansion here, and how can I write test (without violating set -u) for checking that the key x is present in the array?

I know that I can of course write an explicit loop over the keys (i.e. for k in ${(k)arr}, but I suspect that there must be an easier way to accomplish this.

How to disable Head Tracking on Mac for AirPods in TV app?

Posted: 04 Jan 2022 02:40 AM PST

I'm watching a show on TV app on Mac with AirPods. It tracks my head position so that the sound appears to come from the laptop. How do I turn it off?

I switched this setting off on my iPhone (Settings > Accessibility > AirPods > Follow iPhone), but the head tracking is still enabled in TV app on my Mac.

I'm using AirPods (3rd gen) with my 2021 M1 Pro MacBook Pro 14". MacOS Monterey 12.1.

Emoji panel works very slowly on MBP 13'' M1

Posted: 04 Jan 2022 01:43 AM PST

When pressing the Fn/World Globe key on my MacBook Pro 13'' with the M1 chip (macOS version: 12.1), the emoji panel sometimes spawns slower than expected, and the emoji/special character input in texts is very slow, as the emoji gets written in the text 1 second later after selecting it. This is something that slows me in writting some texts with emojis, such as messages to other people.

It happens since way before I upgraded to Monterey, when I was using Big Sur.

Anyone else have a clue about this? Thanks in advance.

Apple Notes subfolders disappearing in iCloud browser version

Posted: 04 Jan 2022 01:30 AM PST

First question to the forum. Thanks ahead of time for any assistance.

I believe I saw one other question asked about this same issue recently, but I felt it wasn't properly explained by the original poster so thought I'd start a new thread here. Hope this is allowed.

The short version is that the subfolders from my Notes no longer display in the iCloud browser version of Notes. The subfolders show in the app on my iPhone 8 and MacBook Pro, but do not appear within the browser version. To clarify, this happens on both my MacBook Pro and Windows 10 desktop, so it seems to be a problem with the browser version, not specific to Windows. The problem seems to have aligned with the latest iOS 15 update (currently 15.2), though I can't confirm this is the cause.

I use an iPhone 8 and sync my Notes through iCloud to use on my Windows 10 desktop. As the only available way to sync Notes from Mac to Windows, I login to iCloud through my browser (typically Chrome) to access my synced Notes. All of my Notes are synced, the only thing that has changed is that the subfolders in the index bar on the left are no longer present. This means the only way to navigate to subfolders and the notes within them is by scrolling through the "All iCloud" folder.

For obvious reasons, this makes organizing and using my Notes quite onerous on my desktop. Unfortunately, if this remains an issue, I may have to switch to a 3rd-party app moving forward, but would really like to avoid this, if possible. I haven't been able to find a fix, and any info or advice would be most welcome.

Thanks for any and all help with this!

David

How extract a snapshot from a Time Machine backup to a new external HD partion so that this partion can act as a (boot) volume?

Posted: 03 Jan 2022 10:32 PM PST

I found out how to extract a snapshot from a Time Machine backup to an external hard drive. I use:

sudo tmutil restore /Volumes/TMdrive/Backups.backupdb/machinename/2021-11-30-042315/MyHD /Volumes/Safety-HD  

(where Safety-HD is the external HD and TMdrive is my Time Machine backup drive).

However after running this command (and waiting for a day or so) when I look at the resulting file system on the new external HD Safety-HD I notice the files and folders from the normal machine root (like Application, Library or System) are inside a folder MyHD:

MyHD --+         |         +- Applications         |         +- Library         |         +- Network         |         +- System         |         +- Users         |         +- ...  

It is obvious that I never be able to make a bootable drive out of this! - How can I tell tmutil to restore to the root of the external drive?

Note 1: I tried the -v option like in sudo tmutil restore -v ..., but I get the same resulting folder structure (plus a very long list of info in the Terminal).

Note 2: I know I can restore to the internal harddrive via Recovery HD, but firstly this doesn't work for external drives, plus it is pretty cumbersome to reboot the whole system when I just want to create a safety bootable drive from an old TM snapshot.

Use HDMI-out on Windows to drive old 30" (Dual-link DVI) Apple monitor

Posted: 03 Jan 2022 09:55 PM PST

I have an AMD Ryzen (TUF Gaming) Windows 10 laptop with a Geforce card and HDMI output. Try what I may, it fails to drive a decade-old 30" dual-link DVI Apple monitor.

My current setup uses two powered convertors:

  1. HDMI -> DisplayPort (powered convertor; Comsol brand)
  2. DisplayPort -> Mini DisplayPort (unpowered adapter; generic)
  3. Mini DisplayPort to Dual-link DVI (powered convertor; Apple brand)

However, Windows can't even identify a monitor is connected. The Cinema Display has a black screen with power light on.

In the past, I successfully used links #2 and 3 of this chain with a DisplayPort-enabled laptop. But the new HDMI -> DP convertor (link #1) seems to break the chain.

Any ideas? Even if only to get it working at low resolution?

-- Other things I tried:

  1. Generic USB-C to Mini DisplayPort convertor didn't work. (The laptop has a non-Thunderbolt USB-C 3.1 port)
  2. Mini DisplayPort to DVI adapter (unpowered) as link #3 didn't work either.

What happens when you delete GUID_Partion_Scheme?

Posted: 03 Jan 2022 08:52 PM PST

/dev/disk0 (internal, physical):     #:                       TYPE NAME                    SIZE       IDENTIFIER     0:      GUID_partition_scheme                        *121.3 GB   disk0     1:                        EFI ⁨EFI⁩                     209.7 MB   disk0s1     2:                 Apple_APFS ⁨Container disk1⁩         121.1 GB   disk0s2    /dev/disk1 (synthesized):     #:                       TYPE NAME                    SIZE       IDENTIFIER     0:      APFS Container Scheme -                      +121.1 GB   disk1                                   Physical Store disk0s2     1:                APFS Volume ⁨Macintosh HD - Data⁩     67.6 GB    disk1s1     2:                APFS Volume ⁨Preboot⁩                 408.1 MB   disk1s2     3:                APFS Volume ⁨Recovery⁩                622.8 MB   disk1s3     4:                APFS Volume ⁨VM⁩                      4.3 GB     disk1s4     5:                APFS Volume ⁨Macintosh HD⁩            22.1 GB    disk1s5     6:              APFS Snapshot ⁨com.apple.os.update-...⁩ 22.1 GB    disk1s5s1  

Can you COMPLETELY disable desktop switching animation on macOS?

Posted: 04 Jan 2022 12:50 AM PST

I reduced animation and transition in macOS but not completely disabled

As some people already discussed, one can "reduce motion" in accessibility settings, use defaults write to "disable" some animations, or use software like TinkerTool. But after all of that, when I switch desktops using Ctrl + Left or Ctrl + Right, macOS still displays a "fade in, fade out" animation for a few deciseconds, which is fine. But

the window focus remains messed up for a while.

Either the window on the previous desktop is still focused, or no windows are focused, for about 1 second, and I cannot perform any operation, which is super annoying and slows down my workflow.

A workaround

is to use Cmd + Tab to switch apps, or use Ctrl + 1-9 to jump to a specific desktop. In this way, the window focus is corrected. But this is a workaround, not a solution.

Modification I did

  • Every setting in TinkerTool.app that disables animation
  • "Reduce motion" in macOS accessibility settings
  • Some scripts, the one related to this is
defaults write com.apple.dock expose-animation-duration -float 0.1  

previous discussion about this

How can I disable animation when switching desktops in Lion? talked about posting a bug and TotalSpaces.
How do you completely disable the space-switching animations in OS X Yosemite? concluded that there's no solution.
Disabling desktop switching animation on El Capitan. Solution has same problem as I have.
How can I disable animation when switching desktops in El Capitan? talked about TotalSpaces and disabling SIP.

Chrome or Mac OS automatically deletes github diffs on download

Posted: 03 Jan 2022 03:41 PM PST

I've been trying to save a simple GitHub PR diff to my downloads folder. The moment it saves, I can't open it because it vanishes and Chrome shows "removed" on the download.

screenshot of download removed

What could be causing this?

Free-form screenshots on Mac

Posted: 03 Jan 2022 03:59 PM PST

I know I can take screenshots of regions using the cmd + shift + 3/4/5 keys on the Mac. But I want to be able to select a specific non-rectangular region to capture.

How do I capture freehand screenshots on the Mac?

I believe this feature is also called "polygon" or "free-form" snipping.

Additionally, I also know that I can take a large screenshot and then take free-form screenshots using Preview with the Lasso Selection tool. But I want to be able to take a freeform screenshot directly without having to use Preview intermediately.

How to disable .zsh_history & .zsh_sessions on macOS?

Posted: 03 Jan 2022 07:08 PM PST

By default in macOS zsh stores the history and sessions in the ~/.zsh_history & ~/.zsh_sessions files.

However for one of my computers I want no Terminal/zsh history or session to be stored what so ever.

Is there a way to disable this behavior in zsh?

External bluetooth keyboard and mouse not detected at login screen after reboot

Posted: 04 Jan 2022 12:07 AM PST

I have a Macbook Pro 15 2018 and Logitech Mx Keys and Mx Master 3 (bluetooth keyboard and mouse) and they are working great.

However when I reboot my mac and get to login screen they are not detected/connected.

When I open the lid and login using the built in keyboard they start working again.

I've found that this my be linked to FileVault and yes I am using FileVault.

My question:

Is there any way to prevent this from happening without turning FileVault off ?

When I put mac to sleep they still keep working and I can wake my mac by pressing a key on the keyboard.

How extract a Time Machine snapshot as a full machine volume?

Posted: 03 Jan 2022 10:35 PM PST

From an old Time Machine backup (Backups.backupdb folder) on a physical external disk I would like to extract some snapshots to other external disks as complete machine volumes. These resulting volumes don't need to be bootable, but if they are, even better.

How can I do this? A command line solution would be the best. I had a look at hdiutil, but wasn't sure whether it can help with this problem.

Background:

I am coming to this because I would like to archive old Time Machine backups (El Capitan system), but I have huge problems to copy the whole Time Machine folder to other locations. (I'm now on Mojave.)

Therefore I thought I extract instead some snapshots of the Time Machine as complete system volumes to separate disk images. These volumnes should look like the original disk when the snapshot was created.

How to hide all toolbars in Excel?

Posted: 04 Jan 2022 12:45 AM PST

I have disabled the Formula Bar and the Ribbon :

Screenshot of view options

But Excel still shows a bunch of tools at the top:

Screenshot of Excel ribbon

I want to de-clutter / simplify the view to only the data and the Menu itself . How can that be done?

Prevent iCloud Drive From Auto-Downloading on Mac

Posted: 03 Jan 2022 11:07 PM PST

Is there a way to stop the auto-downloading of files in iCloud Drive on Mac, and if so, how? I want the files synced with iCloud Drive, but I don't want all the files automatically downloaded. I also don't want to have to completely turn off iCloud Drive on my Mac to prevent this behavior obviously. I don't know why it auto-downloads files uploaded to iCloud Drive on the Mac, but not the iPhone. This behavior is really annoying especially when you only have a 128GB Mac and you have to constantly manually remove the downloaded files. Any tips on what to do here would be appreciated.

How to rename/delete .kext file in Big Sur

Posted: 03 Jan 2022 11:50 PM PST

I have one of those MacBook Pro's (2015) with the hardware fault which causes frequent spontaneous shutdowns.

The problem can be solved by renaming or deleting AppleThunderboltNHI.kext which I have done after every MacOS Catalina update for the past couple of years, basically everything except step 7 & 8 below.

In Big Sur, the change doesn't "stick," the AppleThunderboltNHI.kext file is restored automatically after restarting in normal mode, so I have followed the procedure which works according to many on the discussion referenced below.

Everything goes okay unless I do step 8, at which point the MacOS will not boot, I get a message like "...was restarted because of a problem..."

The only thing that seems to fix that, is to reinstall Big Sur from recovery mode, which does work. But then the AppleThunderboltNHI.kext file is restored.

I don't know is causing this procedure to fail. So I'm hoping someone might be able to help me solve it.

Note: The following instructions are not mine, and I am not recommending them as a solution.

https://developer.apple.com/forums/thread/666567?answerId=646500022#646500022

Posted by sf98723

Follow this procedure :

  1. Reboot in rescue mode (reboot while "Cmd + R")

  2. csrutil disable

  3. csrutil authenticated-root disable

  4. reboot in rescue mode

  5. mount -uw /Volumes/[MacOS ]

  6. delete (or rename, or move elsewhere) the AppleThunderboltNHI.kext directory (I've moved all thunderbolt kext directories since I have no needs about this interface, but I think it works only by disabling AppleThunderboltNHI)

  7. REBUILD the extensions cache ! (new has-to-do in Big Sur...) : kmutil install -u --force --volume-root /Volumes/[MacOS ]

  8. DON'T FORGET to create another system snapshot to take these modifications under account at next reboot : bless --folder /Volumes/[MacOS ]/System/Library/CoreServices --bootefi --create-snapshot

  9. csrutil enable (mays be you have to reboot in rescue mode.. not tested)

  10. Finally, reboot in normal mode

How to delete hidden login iterms from backgrounditems.btm? CML way is prefered

Posted: 04 Jan 2022 01:30 AM PST

I am running MacOS Big Sur. I installed some apps downloaded online. I found out many apps were started automatically at startup.

By googling and examining my system, I figured out they were started from the file backgrounditems.btm which is located at ~/Library/Application Support/com.apple.backgroundtaskmanagementagent/. The file stores Login Items.

By running a python script downloaded online, I can see many Login Items registerd in the file backgrounditems.btm and they are NOT shown in System Preferences > Users > myuser > Login Iterms.

I tried the command osascript -e 'tell application "System Events" to delete login item "name"' to delete the hidden login iterm, but failed with error message "36:73: execution error: System Events got an error: Can't get login item "myapp.app". (-1728)"

These hidden login iterms are also NOT shown when I use the command osascript -e 'tell application "System Events" to get the name of every login item'.

So my question is how to remove those unwanted login iterms to stop them autostart at my login. Command Line Way is prefered. I think some GUI apps such as ccleaner may do the job, but I don't want to install some GUI apps which may be autostarted themselves. Basically, I don't want to install an autostart iterm to remove autostart items.

Thanks a lot.

Update

I figured out the file is in a binary plist format.

Then I tried two tools.

One is the default cml tool plutil. Another one is a thirdy party tool ProperTree. Both can convert and open the binary plist as XML plain plist. But even with a plain plist format, it's kinda hard to understand it. The important sections are still coded in base64 format in xml.

I can decode base64 with many tools, but I still feel it's kinda too much work for this purpose. Do anyone know any easier way to remove hidden login iterms from the file? Thanks.

Copy a table in a Microsoft Word document, using AppleScript

Posted: 04 Jan 2022 03:05 AM PST

I have several hundred MS Word documents containing a single table in each. I need to copy the table, paste into Preview and save as jpeg. I can get Word to find the table, but cannot get the "copy object..." command to work. Suggestions welcome!

tell application "Microsoft Word"      activate      tell document 1          count (tables)          --  set firstTable to item 1 of tables — this does not work. Why?          set table_list to tables          set firstTable to item 1 of table_list          tell firstTable              allow page breaks              -- allow page breaks (false) -- syntax error, () not allowed. Why?              set allow page breaks to false -- This does not work either.              allow page breaks          end tell          select firstTable -- this works! Now what?          copy object firstTable --error -1708; doesnt understand "copy object"      end tell  end tell  

How can I debug a user LaunchAgent that doesn't seem to start or load with launchctl?

Posted: 04 Jan 2022 01:12 AM PST

Problem Description

Running the following user LaunchAgent does not show a started job, nor does the job log an error or do anything detectable. The Vault commands embedded in the plist file work fine when run from a user crontab or the command line, though. I've run the following commands as a non-root user:

# returns exit status 3  launchctl start local.localhost.RenewVaultToken.plist  echo $?    # also returns exit status 3  launchctl enable gui/$UID/local.localhost.RenewVaultToken  launchctl start gui/$UID/local.localhost.RenewVaultToken  echo $?    # returns "Load failed: 5: Input/output error"  launchctl load gui/$UID/local.localhost.RenewVaultToken    # no results  launchctl list | fgrep -i vault  

Tailing the system log doesn't show anything identifiable, nor are any log files created. As far as I can tell, the job can't/won't start or run, but I'm not sure how to effectively debug it further.

LaunchAgent File Contents

I have the following file stored in ~/Library/LaunchAgents with the filename local.localhost.RenewVaultToken.plist. The file is set to mode 0600.

<?xml version="1.0" encoding="UTF-8"?>  <!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0/EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">    <!-- ~/Library/LaunchAgents/local.localhost.RenewVaultToken.plist -->  <plist version="1.0">      <dict>          <key>Label</key>          <string>local.localhost.RenewVaultToken</string>            <key>ProgramArguments</key>          <array>              <string>/usr/local/bin/vault</string>              <string>token</string>              <string>renew</string>              <string>-increment=12h</string>              <string>-address="https://vault.example.com"</string>          </array>            <key>StartInterval</key>          <integer>14400</integer>            <key>RunAtLoad</key>          <true/>            <key>Debug</key>          <true/>            <key>StandardOutPath</key>          <string>/Users/foo/stdout.log</string>            <key>StandardErrorPath</key>          <string>/Users/foo/stderr.log</string>      </dict>  </plist>  

How to start a service for ssh socks proxy?

Posted: 04 Jan 2022 01:27 AM PST

I want to start the following command as a service on Mac OS X. Could anybody show me what is the correct way to do it on Catalina? Thanks.

$ ssh -D 1337 -q -C -N -f user@ma.ttias.be  

https://ma.ttias.be/socks-proxy-linux-ssh-bypass-content-filters/

Troubleshoot slow Big Sur wired network

Posted: 03 Jan 2022 06:07 PM PST

The wired network on my iMac is uncomfortably slow. Google's speed test (just for one quick and easy metric) frequently dips down to about 1 Mbps for downloads. A separate laptop on the same network at the same time, but through WiFi, will consistently show 250 Mbps.

Sometimes connecting the iMac to WiFi seems to improve speeds a bit. Sometimes they improve on their own. In any case the iMac never sees more than half the speeds a laptop does.

This is a new problem immediately after upgrading to Big Sur (i.e., no other changes to the system or network). I'm therefore assuming this is something to do with macOS. But I am at a loss to even begin to know how to troubleshoot the problem.

What in macOS can I check or tweak or investigate to get any handle on what's even happening, much less how to fix it?

Why am I getting bad distortion on my MacBook Pro 15, mid 2015 right speaker?

Posted: 03 Jan 2022 07:06 PM PST

My MacBook Pro 15, mid 2015, has bad distortion on the right speaker. Headphones and bluetooth are fine, and when I use the Audio MIDI utility to swap channels it stays on the right speaker. I installed another right speaker I bought online, but the problem persists. Neither speaker had a broken cone, and the distortion sounds more electronic anyway.

Either:

  1. I got a replacement speaker with the same problem. Since it was used, this is possible but seems unlikely given that my searches online don't suggest that this is a common problem.
  2. I somehow managed to get the old one I removed mixed up with the new one, and put the old one back in. Possible as I'm a old fart, but I labeled the old one as "bad" to avoid this, and the one in my junk box is labeled "bad". Tho still possible that it was the labeling where I spaced out, but would require me to have been even more of a screw up than I usually am.
  3. There is some sort of preamp on the sound/mother/other board that has blown.
  4. There is some sort of software issue that is overdriving some amp somewhere.

I can solve #2 by doing the swap again, but it required more futzing inside the case than I like to do, always worried my fat fingers are going to break something else when I have to go that deep. Maybe it's possible to just plug the bad-labeled speaker in to test it, but I hate actually booting the thing with the back off.

It was pretty cheap, tho I don't recall where I got it, so if I could eliminate #2, #3, and 4, I'll just buy a new one.

Can any of you help me eliminate #3 and #4?

Leaving the last 9 characters of a filename in Automator

Posted: 03 Jan 2022 04:05 PM PST

I have a ton of files to rename where we only need the last 9 characters of the file.

The files are currently named as this: FirstName_LastName_000000000.pdf. Essentially, I want to rename the files so that they are named as such: 000000000.pdf

If somebody can assist with providing a way of doing so that will be awesome.

MacOS Catalina terminal tab doesn't remember its own previous commands

Posted: 03 Jan 2022 05:08 PM PST

I upgraded from El Capitan to Catalina recently; when I click in any terminal tab it used to toggle previous commands executed within that specific tab only, but now it will show commands for all tabs which is very annoying

Is there any setting to fix that?

VirtualBox 5.2 Won't Install on Mac OS 10.13

Posted: 03 Jan 2022 09:53 PM PST

Trying to install VirtualBox 5.2 on a Mac running OSX 10.13. The installation fails with an installer message reading "The installation failed."

I've tried the 2 solutions I've been able to find and neither have worked.

I tried clicking "allow" in the "Security & Privacy" preference panel where the download gets blocked. Each time, I ejected the image before trying again with no luck.

I also tried entering sudo spctl --master-disable in the terminal before trying again, but still no luck.

After the failure, the application icon does still appear in the downloads folder, but I'm supposing this isn't a good installation and I'll run into problems using it? Thoughts?

Safari: Any way to initiate pinch-to-zoom without trackpad?

Posted: 03 Jan 2022 06:38 PM PST

Command + (Zoom in) and Command - (Zoom out) are different from pinch-to-zoom on a trackpad. The former changes the layout of the page, whereas the latter just enlarges the page as if a magnifier was used.

Is there any way to initiate pinch-to-zoom without a trackpad? Any methods such as a keyboard shortcut or an API.

Can I prevent OS X from resizing and moving windows when sleeping while attached to an external monitor?

Posted: 03 Jan 2022 08:51 PM PST

I have my Retina Macbook Pro connected to a ASUS 2560x1440 display via the HDMI port. I keep the laptop lid closed so the monitor is the only display in use.

When I sleep my computer (via hot corners if it matters) and wake it back up, all the windows are resized and in the upper left hand corner. My assumption is that it is resizing and repositioning them for the built in display. Is there a way to prevent this from happening so I don't have to resize and move all my windows when I use the computer again?

Bind each keyboard layout to keys combination

Posted: 03 Jan 2022 04:21 PM PST

There is a nice possibility to bind each keyboard layout to separate keys combination and switch between them.

So you can assign, for instance, shortcut Alt-Shift-0 to "Select English", Alt-Shift-1 to "Select German", Alt-Shift-2 to "Select Arabic".

How to make this on MacOS 10.7.4?

How to search for a file by a hash value with bash script (terminal)?

Posted: 03 Jan 2022 04:05 PM PST

I am writing a script for Mac OS X Lion 10.7 and I would like to know how I can search for files based on their SHA1 hashes. I would like to search the whole file system for the file(s) I will be looking for.

For example the SHA1 value 0d882ff2d5edd7d045c1b57320d2e046793868f8 corresponds to the file MacOSXUpdCombo10.7.2.dmg How can I search the hard drive for the file with its SHA1 value without needing to compare the file?

No comments:

Post a Comment