-
Notifications
You must be signed in to change notification settings - Fork 309
Add instructions on fixing Failed to open device on Linux #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Talinx
wants to merge
3
commits into
the-via:main
Choose a base branch
from
Talinx:linux-failed-to-open-device
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import React from 'react'; | ||
| import styled from 'styled-components'; | ||
| import { AccentButtonLarge } from '../inputs/accent-button'; | ||
|
|
||
| interface InformationModalProps { | ||
| children?: React.ReactNode; | ||
| closeModal: Function; | ||
| } | ||
|
|
||
| const ModalBackgroundDiv = styled.div` | ||
| background-color: rgba(0,0,0,0.7); | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| position: fixed; | ||
| right: 0; | ||
| top: 0; | ||
| justify-content: center; | ||
| align-content: center; | ||
| height: 100%; | ||
| width: 100%; | ||
| z-index: 2; | ||
| padding: 0; | ||
| margin: 0; | ||
| `; | ||
|
|
||
| const ModalDiv = styled.div` | ||
| background: var(--bg_gradient); | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: center; | ||
| align-content: center; | ||
| height: wrap-content; | ||
| max-width: 80em; | ||
| border: 0.5em solid var(--border_color_cell); | ||
| border-radius: 0.5em; | ||
| padding: 1em; | ||
| `; | ||
|
|
||
| export const InformationModal: React.FC<InformationModalProps> = ({ children, closeModal }) => ( | ||
| <ModalBackgroundDiv> | ||
| <ModalDiv> | ||
| {children} | ||
| <AccentButtonLarge onClick={() => closeModal()}>Okay</AccentButtonLarge> | ||
| </ModalDiv> | ||
| </ModalBackgroundDiv> | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import React from 'react'; | ||
| import styled from 'styled-components'; | ||
| import { IconButtonContainer } from '../inputs/icon-button'; | ||
| import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
| import { IconButtonTooltip } from '../inputs/tooltip'; | ||
| import { faCopy } from '@fortawesome/free-solid-svg-icons'; | ||
|
|
||
| interface MonospaceTextProps { | ||
| text: string; | ||
| } | ||
|
|
||
| const TextComponent = styled.div` | ||
| font-family: monospace; | ||
| position: relative; | ||
| `; | ||
|
|
||
| const ClipboardButtonDiv = styled.div` | ||
| position: absolute; | ||
| top: 0; | ||
| right: 0; | ||
| `; | ||
|
|
||
| export const MonospaceText: React.FC<MonospaceTextProps> = ({ text }) => { | ||
| return ( | ||
| <TextComponent> | ||
| <ul> | ||
| {text?.split('\n').map((line, i) => ( | ||
| <li key={i}> | ||
| {line.split('').map((char, i) => { | ||
| if (char === '\t') { | ||
| return <> | ||
| <span> </span> | ||
| <span> </span> | ||
| <span> </span> | ||
| <span> </span> | ||
| </> | ||
| } | ||
| if (char === ' ') { | ||
| return <span> </span>; | ||
| } | ||
| return <span>{char}</span> | ||
| })} | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| <ClipboardButtonDiv> | ||
| <IconButtonContainer onClick={() => navigator.clipboard.writeText(text)}> | ||
| <FontAwesomeIcon | ||
| size={'sm'} | ||
| color="var(--color_label)" | ||
| icon={faCopy} | ||
| /> | ||
| <IconButtonTooltip>Copy to clipboard</IconButtonTooltip> | ||
| </IconButtonContainer> | ||
| </ClipboardButtonDiv> | ||
| </TextComponent> | ||
| ) | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { MonospaceText } from 'src/components/monospace-text'; | ||
| import { DeviceInfo } from 'src/types/types'; | ||
|
|
||
| const LinuxHidrawFix = (deviceInfo: DeviceInfo): () => JSX.Element => { | ||
| const textUdev = `SUBSYSTEM=="usb", ATTR{idVendor}=="${deviceInfo.vendorId.toString(16).toUpperCase().padStart(4, '0')}", ATTR{idProduct}=="${deviceInfo.productId.toString(16).toUpperCase().padStart(4, '0')}", TAG+="uaccess"" | ||
| KERNEL=="hidraw*", MODE="0660", TAG+="uaccess", TAG+="udev-acl"` | ||
|
|
||
| const textDevHidraw = `#!/bin/bash | ||
| HID_NAME='${deviceInfo.productName}' | ||
| # loop over possible devices | ||
| for f in /dev/hidraw* | ||
| do | ||
| DEVICE_NAME=$(basename \${f}) | ||
| if grep "$HID_NAME" "/sys/class/hidraw/\${DEVICE_NAME}/device/uevent"; | ||
| then | ||
| # device matches product name | ||
| echo Running sudo chmod a+rw "$f" | ||
| sudo chmod a+rw "$f" | ||
| fi | ||
| done`; | ||
|
|
||
| const textRunDevHidrawScript = `bash script.sh`; | ||
|
|
||
| return () => ( | ||
| <div> | ||
| <p>This error can happen on Linux when the browser is not allowed to access the keyboard HID device. You can fix this either permanently or temporarily.</p> | ||
| <p>Create udev rule to fix it permanently. To do this, create a file called</p> | ||
| {/* Rule has to precede /usr/lib/udev/rules.d/73-seat-late.rules, see https://wiki.archlinux.org/title/Udev#Allowing_regular_users_to_use_devices */} | ||
| <MonospaceText text="/etc/udev/rules.d/50-qmk.rules" /> | ||
| <p>with the following content:</p> | ||
| <MonospaceText text={textUdev} /> | ||
| <p>Unplug and plug your keyboard back in. Reload this website and it should work.</p> | ||
| <p>If you want to temporarily allow the browser access to the keyboard device, create a script with the following content:</p> | ||
| <MonospaceText text={textDevHidraw} /> | ||
| <p>And run it:</p> | ||
| <MonospaceText text={textRunDevHidrawScript} /> | ||
| <p>Reload this website and it should work.</p> | ||
| </div> | ||
| ) | ||
| }; | ||
|
|
||
| export function getUserFixForError(e: any, deviceInfo: DeviceInfo): [boolean, () => JSX.Element | undefined] { | ||
| if (e instanceof DOMException) { | ||
| if (e.name === 'NotAllowedError' && e.message.includes('Failed to open the device')) { | ||
| return [true, LinuxHidrawFix(deviceInfo)]; | ||
| } | ||
| } | ||
| return [false, () => undefined]; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've got a double quote too many at the end of line 5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching!