Skip to content

Commit

Permalink
Mount system volume read-write on Catalina
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Belyaev committed Oct 15, 2019
1 parent 31f7a6a commit 6684f46
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 27 deletions.
42 changes: 21 additions & 21 deletions Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14269.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14868" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14269.12"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14868"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand All @@ -12,11 +12,11 @@
<application id="hnw-xV-0zn" sceneMemberID="viewController">
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
<items>
<menuItem title="RDM-2" id="1Xt-HY-uBw">
<menuItem title="RDM" id="1Xt-HY-uBw">
<modifierMask key="keyEquivalentModifierMask"/>
<menu key="submenu" title="RDM-2" systemMenu="apple" id="uQy-DD-JDr">
<menu key="submenu" title="RDM" systemMenu="apple" id="uQy-DD-JDr">
<items>
<menuItem title="About RDM-2" id="5kV-Vb-QxS">
<menuItem title="About RDM" id="5kV-Vb-QxS">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="orderFrontStandardAboutPanel:" target="Ady-hI-5gd" id="Exp-CZ-Vem"/>
Expand All @@ -30,7 +30,7 @@
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
</menuItem>
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
<menuItem title="Hide RDM-2" keyEquivalent="h" id="Olw-nP-bQN">
<menuItem title="Hide RDM" keyEquivalent="h" id="Olw-nP-bQN">
<connections>
<action selector="hide:" target="Ady-hI-5gd" id="PnN-Uc-m68"/>
</connections>
Expand All @@ -48,7 +48,7 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
<menuItem title="Quit RDM-2" keyEquivalent="q" id="4sb-4s-VLi">
<menuItem title="Quit RDM" keyEquivalent="q" id="4sb-4s-VLi">
<connections>
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
</connections>
Expand Down Expand Up @@ -620,7 +620,7 @@
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleSourceList:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
<action selector="toggleSidebar:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
</connections>
</menuItem>
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">
Expand Down Expand Up @@ -711,21 +711,21 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YEp-6x-6rH">
<rect key="frame" x="20" y="53" width="440" height="159"/>
<rect key="frame" x="20" y="53" width="440" height="160"/>
<clipView key="contentView" id="MbI-bM-EBh">
<rect key="frame" x="1" y="0.0" width="438" height="158"/>
<rect key="frame" x="1" y="0.0" width="438" height="159"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" headerView="8db-ve-2Wq" viewBased="YES" id="Zid-hf-sRF">
<rect key="frame" x="0.0" y="0.0" width="438" height="133"/>
<autoresizingMask key="autoresizingMask"/>
<rect key="frame" x="0.0" y="0.0" width="438" height="134"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn identifier="horizontalResolution" width="116" minWidth="40" maxWidth="1000" id="ecv-tP-yVq">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Horizontal">
<font key="font" metaFont="smallSystem"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
Expand Down Expand Up @@ -759,7 +759,7 @@
</tableColumn>
<tableColumn identifier="verticalResolution" width="116" minWidth="40" maxWidth="1000" id="mnP-m7-XI8">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Vertical">
<font key="font" metaFont="smallSystem"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
Expand Down Expand Up @@ -793,7 +793,7 @@
</tableColumn>
<tableColumn identifier="hiDPI" width="197" minWidth="10" maxWidth="3.4028234663852886e+38" id="8Fp-Oj-olE">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="HiDPI">
<font key="font" metaFont="smallSystem"/>
<font key="font" metaFont="menu" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</tableHeaderCell>
Expand Down Expand Up @@ -830,11 +830,11 @@
</tableView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="zvJ-T0-9WW">
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="zvJ-T0-9WW">
<rect key="frame" x="1" y="213" width="438" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="qOU-Dy-Ymr">
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="qOU-Dy-Ymr">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
Expand All @@ -854,7 +854,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="83i-KI-4SF">
<rect key="frame" x="21" y="20" width="21" height="21"/>
<rect key="frame" x="21" y="20" width="21" height="20"/>
<constraints>
<constraint firstAttribute="width" constant="21" id="jnq-zh-PQV"/>
</constraints>
Expand All @@ -867,7 +867,7 @@
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="JHu-Hi-3JO">
<rect key="frame" x="50" y="20" width="21" height="21"/>
<rect key="frame" x="50" y="20" width="21" height="20"/>
<constraints>
<constraint firstAttribute="width" constant="21" id="pdV-sD-fZJ"/>
</constraints>
Expand All @@ -881,7 +881,7 @@
</connections>
</button>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ayq-Wa-lly">
<rect key="frame" x="172" y="228" width="136" height="22"/>
<rect key="frame" x="172" y="229" width="136" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="136" id="vhL-yw-VFu"/>
</constraints>
Expand All @@ -892,7 +892,7 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="keD-Ag-1yZ">
<rect key="frame" x="129" y="23" width="223" height="17"/>
<rect key="frame" x="129" y="23" width="223" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Reboot is required to apply changes" id="77u-WF-Svg">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
Expand Down
16 changes: 10 additions & 6 deletions ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,12 @@ import Cocoa
p.standardOutput = pipe
p.launch()
let data = pipe.fileHandleForReading.readDataToEndOfFile()

let disabledProtections = ["System Integrity Protection status: disabled.", "Filesystem Protections: disabled"]

let enabled = p.terminationStatus == 0 &&
String(data: data, encoding: String.Encoding.utf8)!.split(separator: "\n")
.allSatisfy({ (s : Substring) -> Bool in
let line = s.trimmingCharacters(in: CharacterSet.whitespaces)
return line != "System Integrity Protection status: disabled." && line != "Filesystem Protections: disabled"
})
.allSatisfy({ return !disabledProtections.contains($0.trimmingCharacters(in: CharacterSet.whitespaces)) })

if enabled {
let alert = NSAlert()
Expand All @@ -77,7 +76,7 @@ import Cocoa
self.view.window!.close()
}
}
plist = NSMutableDictionary.init(contentsOf: URL.init(fileURLWithPath: fileName)) ?? NSMutableDictionary()

resolutions = [Resolution]()
Expand Down Expand Up @@ -153,8 +152,13 @@ import Cocoa
plist.setValue(resArray, forKey: "scale-resolutions")
let tmpFile = NSTemporaryDirectory() + "tmp"
plist.write(toFile: tmpFile, atomically: false)

var mountSystemReadWrite = ""
if ProcessInfo().isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: 10, minorVersion: 15, patchVersion: 0)) {
mountSystemReadWrite = "mount -uw / && "
}

let myAppleScript = "do shell script \"mkdir -p \(dir) && cp \(tmpFile) \(fileName)\" with administrator privileges"
let myAppleScript = "do shell script \"\(mountSystemReadWrite)mkdir -p \(dir) && cp \(tmpFile) \(fileName)\" with administrator privileges"

var error: NSDictionary?
if let scriptObject = NSAppleScript(source: myAppleScript) {
Expand Down

0 comments on commit 6684f46

Please sign in to comment.