[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Fix volume up/down shortcut

Kasper (Sep 12, 2024, 2:08 AM +0200) 3e22dba4 4c36a33c

+29 -3
+16 -1
src/App.svelte
··· 16 16 import type { TrackID } from 'ferrum-addon/addon' 17 17 import { modalCount } from './components/Modal.svelte' 18 18 import QuickNav from './components/QuickNav.svelte' 19 + import { checkShortcut } from './lib/helpers' 19 20 20 21 ipcRenderer.emit('appLoaded') 21 22 ··· 166 167 <title>Ferrum</title> 167 168 </svelte:head> 168 169 169 - <main on:dragenter|capture={dragEnterOrOver}> 170 + <!-- svelte-ignore a11y-no-noninteractive-element-interactions --> 171 + <main 172 + on:dragenter|capture={dragEnterOrOver} 173 + on:keydown={(e) => { 174 + if (e.target) { 175 + if (checkShortcut(e, 'ArrowUp', { cmdOrCtrl: true })) { 176 + e.preventDefault() 177 + ipcRenderer.invoke('volume_change', true) 178 + } else if (checkShortcut(e, 'ArrowDown', { cmdOrCtrl: true })) { 179 + e.preventDefault() 180 + ipcRenderer.invoke('volume_change', false) 181 + } 182 + } 183 + }} 184 + > 170 185 <div class="meat"> 171 186 <Sidebar /> 172 187 <TrackList {onTrackInfo} />
+10 -2
src/electron/ipc.ts
··· 14 14 15 15 ipcMain.handle('showOpenDialog', async (e, attached, options) => { 16 16 const window = BrowserWindow.fromWebContents(e.sender) 17 - if (attached === true && window) { 17 + if (attached && window) { 18 18 return await dialog.showOpenDialog(window, options) 19 19 } else { 20 20 return await dialog.showOpenDialog(options) 21 21 } 22 22 }) 23 23 24 - ipcMain.handle('revealTrackFile', async (e, ...paths) => { 24 + ipcMain.handle('revealTrackFile', async (_e, ...paths) => { 25 25 shell.showItemInFolder(path.join(...paths)) 26 + }) 27 + 28 + ipcMain.handle('volume_change', async (_e, up) => { 29 + if (up) { 30 + Menu.getApplicationMenu()?.getMenuItemById('Volume Up')?.click() 31 + } else { 32 + Menu.getApplicationMenu()?.getMenuItemById('Volume Down')?.click() 33 + } 26 34 }) 27 35 28 36 ipcMain.handle('showTrackMenu', (e, options) => {
+2
src/electron/menubar.ts
··· 233 233 }, 234 234 { type: 'separator' }, 235 235 { 236 + id: 'Volume Up', 236 237 label: 'Volume Up', 237 238 accelerator: 'CmdOrCtrl+Up', 238 239 click: () => { ··· 240 241 }, 241 242 }, 242 243 { 244 + id: 'Volume Down', 243 245 label: 'Volume Down', 244 246 accelerator: 'CmdOrCtrl+Down', 245 247 click: () => {
+1
src/electron/typed_ipc.ts
··· 150 150 revealTrackFile: (...paths: string[]) => void 151 151 showTrackMenu: (options: ShowTrackMenuOptions) => void 152 152 showTracklistMenu: (options: { id: string; isFolder: boolean; isRoot: boolean }) => void 153 + volume_change: (up: boolean) => void 153 154 154 155 'update:Shuffle': (checked: boolean) => void 155 156 'update:Repeat': (checked: boolean) => void