Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
incognitojam committed Jan 24, 2025
1 parent c7eca7c commit e020c6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/app/Flash.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback, useState } from 'react'

import { Step, Error, useQdl } from '../utils/flash'
import { isLinux } from '../utils/platform'

import bolt from '../assets/bolt.svg'
import cable from '../assets/cable.svg'
Expand Down Expand Up @@ -115,8 +116,7 @@ const errors = {
},
}

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";
const isLinux = navigator.userAgent.toLowerCase().includes('linux');
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";

function LinearProgress({ value, barColor }) {
if (value === -1 || value > 100) value = 100
Expand Down Expand Up @@ -252,23 +252,24 @@ export default function Flash() {
<div className="w-full max-w-3xl px-8 transition-opacity duration-300" style={{ opacity: progress === -1 ? 0 : 1 }}>
<LinearProgress value={progress * 100} barColor={bgColor} />
</div>
<span className={`text-3xl dark:text-white font-mono font-light`}>{title}</span>
<span className={`text-xl dark:text-white px-8 max-w-xl`}>{description}</span>
{(title === "Lost connection" || title === "Ready") && isLinux && (
<span className="text-3xl dark:text-white font-mono font-light">{title}</span>
<span className="text-xl dark:text-white px-8 max-w-xl">{description}</span>
{(title === "Ready" || title === "Lost connection") && isLinux && (
<>
<span className={`text-l dark:text-white px-2 max-w-xl`}>
It seems that you&apos;re on Linux, make sure to run the script below in your terminal after plugging in your device.
<span className="text-l dark:text-white px-2 max-w-xl">
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.
Run the script below in your terminal after plugging in your device.
</span>
<div className="relative mt-2 max-w-3xl">
<div className="bg-gray-200 dark:bg-gray-800 rounded-md overflow-x-auto">
<div className="relative">
<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">
{detachScript}
{DETACH_SCRIPT}
</pre>
<div className="absolute top-2 right-2">
<button
onClick={() => {
navigator.clipboard.writeText(detachScript);
void navigator.clipboard.writeText(DETACH_SCRIPT);
handleCopy();
}}
className={`bg-${copied ? 'green' : 'blue'}-500 text-white px-1 py-1 rounded-md ml-2 text-sm`}
Expand Down
1 change: 1 addition & 0 deletions src/utils/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ const platform = (() => {
})()

export const isWindows = !platform || platform === 'Windows'
export const isLinux = platform === 'Linux'

0 comments on commit e020c6d

Please sign in to comment.