Skip to content

Commit e020c6d

Browse files
committed
cleanup
1 parent c7eca7c commit e020c6d

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

src/app/Flash.jsx

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useCallback, useState } from 'react'
22

33
import { Step, Error, useQdl } from '../utils/flash'
4+
import { isLinux } from '../utils/platform'
45

56
import bolt from '../assets/bolt.svg'
67
import cable from '../assets/cable.svg'
@@ -115,8 +116,7 @@ const errors = {
115116
},
116117
}
117118

118-
const detachScript = "for d in /sys/bus/usb/drivers/qcserial/*-*; do [ -e \"$d\" ] && echo -n \"$(basename $d)\" | sudo tee /sys/bus/usb/drivers/qcserial/unbind > /dev/null; done";
119-
const isLinux = navigator.userAgent.toLowerCase().includes('linux');
119+
const DETACH_SCRIPT = "for d in /sys/bus/usb/drivers/qcserial/*-*; do [ -e \"$d\" ] && echo -n \"$(basename $d)\" | sudo tee /sys/bus/usb/drivers/qcserial/unbind > /dev/null; done";
120120

121121
function LinearProgress({ value, barColor }) {
122122
if (value === -1 || value > 100) value = 100
@@ -252,23 +252,24 @@ export default function Flash() {
252252
<div className="w-full max-w-3xl px-8 transition-opacity duration-300" style={{ opacity: progress === -1 ? 0 : 1 }}>
253253
<LinearProgress value={progress * 100} barColor={bgColor} />
254254
</div>
255-
<span className={`text-3xl dark:text-white font-mono font-light`}>{title}</span>
256-
<span className={`text-xl dark:text-white px-8 max-w-xl`}>{description}</span>
257-
{(title === "Lost connection" || title === "Ready") && isLinux && (
255+
<span className="text-3xl dark:text-white font-mono font-light">{title}</span>
256+
<span className="text-xl dark:text-white px-8 max-w-xl">{description}</span>
257+
{(title === "Ready" || title === "Lost connection") && isLinux && (
258258
<>
259-
<span className={`text-l dark:text-white px-2 max-w-xl`}>
260-
It seems that you&apos;re on Linux, make sure to run the script below in your terminal after plugging in your device.
259+
<span className="text-l dark:text-white px-2 max-w-xl">
260+
On Linux systems, devices in QDL mode are automatically bound to the kernel&apos;s qcserial driver, and need to be unbound before we can access the device.
261+
Run the script below in your terminal after plugging in your device.
261262
</span>
262263
<div className="relative mt-2 max-w-3xl">
263264
<div className="bg-gray-200 dark:bg-gray-800 rounded-md overflow-x-auto">
264265
<div className="relative">
265266
<pre className="font-mono text-sm text-gray-800 dark:text-gray-200 bg-gray-300 dark:bg-gray-700 rounded-md p-6 flex-grow max-w-m text-wrap">
266-
{detachScript}
267+
{DETACH_SCRIPT}
267268
</pre>
268269
<div className="absolute top-2 right-2">
269270
<button
270271
onClick={() => {
271-
navigator.clipboard.writeText(detachScript);
272+
void navigator.clipboard.writeText(DETACH_SCRIPT);
272273
handleCopy();
273274
}}
274275
className={`bg-${copied ? 'green' : 'blue'}-500 text-white px-1 py-1 rounded-md ml-2 text-sm`}

src/utils/platform.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ const platform = (() => {
99
})()
1010

1111
export const isWindows = !platform || platform === 'Windows'
12+
export const isLinux = platform === 'Linux'

0 commit comments

Comments
 (0)