Skip to content

Commit 1fa77be

Browse files
committed
Update isInProc() to take repeated parameters. Add 'microsoft' as search string
1 parent 9857c74 commit 1fa77be

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/main/scala/introprog/Swing.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ object Swing {
3333
def isOS(partOfName: String): Boolean =
3434
scala.sys.props("os.name").toLowerCase.contains(partOfName.toLowerCase)
3535

36-
/** Check whether `/proc/version` on this filesystem contains the argument `s`. */
37-
def isInProc(s: String): Boolean = {
38-
val cmd = Seq("grep", "-s", "-q", s, "/proc/version")
36+
/** Check whether `/proc/version` on this filesystem contains any of the strings in `s`. */
37+
def isInProc(s: String*): Boolean = {
38+
val searchString = s.mkString("|")
39+
val cmd = Seq("grep", "-i", "-P", "-s", "-q", searchString, "/proc/version")
3940
val p = sys.process.Process(cmd)
4041
util.Try(p.! == 0).getOrElse(false)
4142
}
@@ -50,7 +51,7 @@ object Swing {
5051

5152
private def setPlatformSpecificLookAndFeel(): Unit = {
5253
import javax.swing.UIManager.setLookAndFeel
53-
if (isOS("win") || isInProc("windows") || isInProc("WSL")) findLookAndFeel("win").foreach(setLookAndFeel)
54+
if (isOS("win") || isInProc("windows", "wsl", "microsoft")) findLookAndFeel("win").foreach(setLookAndFeel)
5455
else if (isOS("linux")) findLookAndFeel("gtk").foreach(setLookAndFeel)
5556
else if (isOS("mac")) findLookAndFeel("apple").foreach(setLookAndFeel)
5657
else javax.swing.UIManager.setLookAndFeel(

0 commit comments

Comments
 (0)