feat(ags): replace swayOSD

This commit is contained in:
matt1432 2023-11-10 23:51:50 -05:00
parent 42033f28ac
commit 7cf63fb6c4
23 changed files with 334 additions and 123 deletions

View file

@ -5,7 +5,6 @@
]; ];
nixpkgs.overlays = [ nixpkgs.overlays = [
(import ./swayosd.nix)
(import ./blueberry.nix) (import ./blueberry.nix)
(final: prev: { (final: prev: {

View file

@ -1,27 +0,0 @@
final: prev: {
swayosd = prev.swayosd.overrideAttrs (oldAttrs: rec {
src = prev.fetchFromGitHub {
owner = "ErikReider";
repo = "SwayOSD";
rev = "8159c9e9962ce19f6fb78201d4d34e5817f53b45";
hash = "sha256-kGd4/eQkhvxEL3/LToBDjE/JIR8m6w9vdFUrRTyylCE=";
};
cargoDeps = oldAttrs.cargoDeps.overrideAttrs (prev.lib.const {
name = "swayosd-vendor.tar.gz";
inherit src;
outputHash = "sha256-gRhhPDUFPcDS1xo7JzCpZtd1Al1kEkx2dXf92cc2bUo=";
#outputHash = prev.lib.fakeHash;
});
buildInputs = (oldAttrs.buildInputs or [ ]) ++ [
prev.systemd
];
patches = [
./patches/swayosd.patch
];
});
}

View file

@ -34,6 +34,7 @@
"globals": { "globals": {
"Tablet": "readonly", "Tablet": "readonly",
"Pointers": "readonly", "Pointers": "readonly",
"Brightness": "readonly",
"ARGV": "readonly", "ARGV": "readonly",
"imports": "readonly", "imports": "readonly",
"print": "readonly", "print": "readonly",

View file

@ -2,6 +2,7 @@ import App from 'resource:///com/github/Aylur/ags/app.js';
import { exec } from 'resource:///com/github/Aylur/ags/utils.js'; import { exec } from 'resource:///com/github/Aylur/ags/utils.js';
import Setup from './js/setup.js'; import Setup from './js/setup.js';
import OSD from './js/osd/main.js';
import Powermenu from './js/powermenu.js'; import Powermenu from './js/powermenu.js';
import * as Bar from './js/bar/main.js'; import * as Bar from './js/bar/main.js';
import NotifCenter from './js/notifications/center.js'; import NotifCenter from './js/notifications/center.js';
@ -26,6 +27,7 @@ export default {
'applauncher': 500, 'applauncher': 500,
'calendar': 500, 'calendar': 500,
'notification-center': 500, 'notification-center': 500,
'osd': 500,
'overview': 500, 'overview': 500,
'powermenu': 500, 'powermenu': 500,
'quick-settings': 500, 'quick-settings': 500,
@ -42,6 +44,7 @@ export default {
Bar.BgGradient(), Bar.BgGradient(),
Corners.Bottomleft(), Corners.Bottomleft(),
Corners.Bottomright(), Corners.Bottomright(),
OSD(),
NotifPopups(), NotifPopups(),
], ],
}; };

View file

@ -1,5 +1,4 @@
import { ProgressBar, Overlay, Box } from 'resource:///com/github/Aylur/ags/widget.js'; import { ProgressBar, Overlay, Box } from 'resource:///com/github/Aylur/ags/widget.js';
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
import Separator from '../misc/separator.js'; import Separator from '../misc/separator.js';
import Heart from './heart.js'; import Heart from './heart.js';
@ -9,17 +8,9 @@ export default () => Overlay({
tooltipText: 'Brightness', tooltipText: 'Brightness',
child: ProgressBar({ child: ProgressBar({
className: 'toggle-off brightness', className: 'toggle-off brightness',
connections: [ connections: [[Brightness, self => {
[200, self => { self.value = Brightness.screen > 0.33 ? Brightness.screen : 0.33;
execAsync('brightnessctl get').then(out => { }, 'screen']],
const br = out / 255;
if (br > 0.33)
self.value = br;
else
self.value = 0.33;
}).catch(print);
}],
],
}), }),
overlays: [ overlays: [
Box({ Box({

View file

@ -0,0 +1,48 @@
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
import { Box, Icon, ProgressBar } from 'resource:///com/github/Aylur/ags/widget.js';
const items = {
101: 'audio-volume-overamplified-symbolic',
67: 'audio-volume-high-symbolic',
34: 'audio-volume-medium-symbolic',
1: 'audio-volume-low-symbolic',
0: 'audio-volume-muted-symbolic',
};
export default () => Box({
className: 'osd',
children: [
Icon({
hpack: 'start',
connections: [[Audio, self => {
if (!Audio.speaker)
return;
if (Audio.speaker.stream.isMuted) {
self.icon = items[0];
}
else {
const vol = Audio.speaker.volume * 100;
for (const threshold of [-1, 0, 33, 66, 100]) {
if (vol > threshold + 1)
self.icon = items[threshold + 1];
}
}
const stack = self.get_parent().get_parent();
stack.shown = 'audio';
stack.resetTimer();
}, 'speaker-changed']],
}),
ProgressBar({
vpack: 'center',
connections: [[Audio, self => {
self.value = Audio.speaker ? Audio.speaker.volume / 1.5 : 0;
self.sensitive = !Audio.speaker?.stream.isMuted;
}]],
}),
],
});

View file

@ -0,0 +1,23 @@
import { Box, Icon, ProgressBar } from 'resource:///com/github/Aylur/ags/widget.js';
export default () => Box({
className: 'osd',
children: [
Icon({
hpack: 'start',
icon: 'display-brightness-symbolic',
}),
ProgressBar({
vpack: 'center',
connections: [[Brightness, self => {
self.value = Brightness.screen;
const stack = self.get_parent().get_parent();
stack.shown = 'brightness';
stack.resetTimer();
}, 'screen']],
}),
],
});

View file

@ -0,0 +1,24 @@
import { Box, Icon, Label } from 'resource:///com/github/Aylur/ags/widget.js';
export default () => Box({
className: 'osd',
children: [
Icon({
hpack: 'start',
icon: 'caps-lock-symbolic',
connections: [[Brightness, (self, state) => {
self.icon = state ? 'caps-lock-symbolic' : 'capslock-disabled-symbolic';
const stack = self.get_parent().get_parent();
stack.shown = 'caps';
stack.resetTimer();
}, 'caps']],
}),
Label({
vpack: 'center',
label: 'Caps Lock',
}),
],
});

View file

@ -0,0 +1,55 @@
import App from 'resource:///com/github/Aylur/ags/app.js';
import { timeout } from 'resource:///com/github/Aylur/ags/utils.js';
import { Stack } from 'resource:///com/github/Aylur/ags/widget.js';
import GLib from 'gi://GLib';
import PopupWindow from '../misc/popup.js';
import Audio from './audio.js';
import Brightness from './brightness.js';
import Caps from './caps.js';
import Microphone from './mic.js';
export default () => {
let setup = 0;
const stack = Stack({
css: 'margin-bottom: 80px;',
items: [
['audio', Audio()],
['brightness', Brightness()],
['caps', Caps()],
['mic', Microphone()],
],
});
const window = PopupWindow({
name: 'osd',
anchor: ['bottom'],
closeOnUnfocus: 'stay',
transition: 'slide_up',
transitionDuration: 200,
child: stack,
});
let timer;
stack.resetTimer = () => {
// Each osd calls resetTimer once at startup
if (setup <= stack.items.length + 1) {
++setup;
return;
}
App.openWindow('osd');
if (timer)
GLib.source_remove(timer);
timer = timeout(2000, () => {
App.closeWindow('osd');
timer = undefined;
});
};
return window;
};

View file

@ -0,0 +1,47 @@
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
import { Box, Icon, ProgressBar } from 'resource:///com/github/Aylur/ags/widget.js';
const items = {
67: 'audio-input-microphone-high-symbolic',
34: 'audio-input-microphone-medium-symbolic',
1: 'audio-input-microphone-low-symbolic',
0: 'audio-input-microphone-muted-symbolic',
};
export default () => Box({
className: 'osd',
children: [
Icon({
hpack: 'start',
connections: [[Audio, self => {
if (!Audio.microphone)
return;
if (Audio.microphone.stream.isMuted) {
self.icon = items[0];
}
else {
const vol = Audio.microphone.volume * 100;
for (const threshold of [-1, 0, 33, 66]) {
if (vol > threshold + 1)
self.icon = items[threshold + 1];
}
}
const stack = self.get_parent().get_parent();
stack.shown = 'mic';
stack.resetTimer();
}, 'microphone-changed']],
}),
ProgressBar({
vpack: 'center',
connections: [[Audio, self => {
self.value = Audio.microphone ? Audio.microphone.volume : 0;
self.sensitive = !Audio.microphone?.stream.isMuted;
}, 'microphone-changed']],
}),
],
});

View file

@ -247,7 +247,7 @@ const SecondRow = () => Row({
GridButton({ GridButton({
command: () => { command: () => {
execAsync(['swayosd-client', '--output-volume', 'mute-toggle']) execAsync(['pactl', 'set-source-mute', '@DEFAULT_SOURCE@', 'toggle'])
.catch(print); .catch(print);
}, },
@ -274,7 +274,7 @@ const SecondRow = () => Row({
GridButton({ GridButton({
command: () => { command: () => {
execAsync(['swayosd-client', '--input-volume', 'mute-toggle']) execAsync(['pactl', 'set-source-mute', '@DEFAULT_SOURCE@', 'toggle'])
.catch(print); .catch(print);
}, },

View file

@ -1,6 +1,5 @@
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js'; import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
import { Box, Slider, Icon, EventBox } from 'resource:///com/github/Aylur/ags/widget.js'; import { Box, Slider, Icon, EventBox } from 'resource:///com/github/Aylur/ags/widget.js';
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
const items = { const items = {
101: 'audio-volume-overamplified-symbolic', 101: 'audio-volume-overamplified-symbolic',
@ -71,18 +70,12 @@ export default () => Box({
['canChange', true], ['canChange', true],
], ],
onChange: ({ value }) => { onChange: ({ value }) => {
execAsync(`brightnessctl set ${value}`) Brightness.screen = value;
.catch(print);
}, },
connections: [[1000, slider => { connections: [[Brightness, slider => {
if (slider._canChange) { if (slider._canChange)
execAsync('brightnessctl get') slider.value = Brightness.screen;
.then(out => slider.value = out) }, 'screen']],
.catch(print);
}
}]],
min: 0,
max: 255,
draw_value: false, draw_value: false,
}), }),
}), }),

View file

@ -1,15 +1,17 @@
import App from 'resource:///com/github/Aylur/ags/app.js'; import App from 'resource:///com/github/Aylur/ags/app.js';
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
import Tablet from '../services/tablet.js'; import Brightness from '../services/brightness.js';
import Pointers from '../services/pointers.js'; import Pointers from '../services/pointers.js';
import Tablet from '../services/tablet.js';
import TouchGestures from '../services/touch-gestures.js'; import TouchGestures from '../services/touch-gestures.js';
import closeAll from './misc/closer.js'; import closeAll from './misc/closer.js';
export default () => { export default () => {
globalThis.Tablet = Tablet; globalThis.Brightness = Brightness;
globalThis.Pointers = Pointers; globalThis.Pointers = Pointers;
globalThis.Tablet = Tablet;
globalThis.closeAll = closeAll; globalThis.closeAll = closeAll;
execAsync(['bash', '-c', '$AGS_PATH/startup.sh']).catch(print); execAsync(['bash', '-c', '$AGS_PATH/startup.sh']).catch(print);

View file

@ -2,6 +2,7 @@ $darkbg: #0b0d16;
$bg: rgba(40, 42, 54, 0.8); // rgba(69, 71, 90, 0.3); #0d0f18; $bg: rgba(40, 42, 54, 0.8); // rgba(69, 71, 90, 0.3); #0d0f18;
$bgfull: rgb(40, 42, 54); $bgfull: rgb(40, 42, 54);
$contrast-bg: rgba(189, 147, 249, 0.8); $contrast-bg: rgba(189, 147, 249, 0.8);
$contrast-bg-full: rgba(189, 147, 249, 1);
$bg-secondary: rgba(#382c4a, 0.8); $bg-secondary: rgba(#382c4a, 0.8);
$bg-secondary-alt: #a5b6cf; $bg-secondary-alt: #a5b6cf;
$fg: #a5b6cf; $fg: #a5b6cf;

View file

@ -21,3 +21,4 @@ undershoot {
@import "./widgets/overview"; @import "./widgets/overview";
@import "./widgets/applauncher"; @import "./widgets/applauncher";
@import "./widgets/corners"; @import "./widgets/corners";
@import "./widgets/osd";

View file

@ -0,0 +1,43 @@
.osd {
padding: 12px 20px;
border-radius: 999px;
background: rgba(40, 42, 54, 0.8);
border: 2px solid $contrast-bg;
label {
min-width: 170px;
}
progressbar:disabled {
opacity: 0.5;
}
progressbar {
min-height: 6px;
min-width: 170px;
border-radius: 999px;
background: transparent;
border: none;
trough {
background: #363847;
min-height: inherit;
border-radius: inherit;
border: none;
}
progress {
background: #79659f;
min-height: inherit;
border-radius: inherit;
border: none;
}
}
image {
font-size: 2rem;
color: white;
margin-left: -0.4rem;
margin-right: 0.8rem;
}
}

View file

@ -0,0 +1,65 @@
import Service from 'resource:///com/github/Aylur/ags/service.js';
import { exec, execAsync, readFileAsync } from 'resource:///com/github/Aylur/ags/utils.js';
const KBD = 'tpacpi::kbd_backlight';
const CAPS = '/sys/class/leds/input0::capslock/brightness';
class Brightness extends Service {
static {
Service.register(this, {
'screen': ['float'],
'kbd': ['int'],
'caps': ['int'],
});
}
_kbd = 0;
_screen = 0;
_caps = 0;
get kbd() { return this._kbd; }
get screen() { return this._screen; }
get caps() { return this._caps; }
set kbd(value) {
// TODO
}
set screen(percent) {
if (percent < 0)
percent = 0;
if (percent > 1)
percent = 1;
execAsync(`brightnessctl s ${percent * 100}% -q`)
.then(() => {
this._screen = percent;
this.emit('screen', this._screen);
})
.catch(console.error);
}
constructor() {
super();
try {
this._kbd = Number(exec(`brightnessctl -d ${KBD} g`));
this._kbdMax = Number(exec(`brightnessctl -d ${KBD} m`));
this._screen = Number(exec('brightnessctl g')) / Number(exec('brightnessctl m'));
} catch (error) {
console.error('missing dependancy: brightnessctl');
}
}
fetchCapsState() {
readFileAsync(CAPS)
.then(out => {
this._caps = out;
this.emit('caps', this._caps);
})
.catch(logError);
}
}
const brightnessService = new Brightness();
export default brightnessService;

View file

@ -34,9 +34,6 @@ layerrule = blur, overview
exec-once = wl-paste --watch cliphist store exec-once = wl-paste --watch cliphist store
# OSD window
exec-once = swayosd-server
# Change HandleLidSwitch to lock in logind.conf # Change HandleLidSwitch to lock in logind.conf
exec-once = swayidle -w lock $LOCK_PATH/lock.sh exec-once = swayidle -w lock $LOCK_PATH/lock.sh
@ -244,13 +241,14 @@ bind =, Print, exec, bash -c 'grim -g "$(slurp)" - | swappy -f -'
bind = $mainMod SHIFT, C, exec, wl-color-picker bind = $mainMod SHIFT, C, exec, wl-color-picker
# Volume control # Volume control
binde =, XF86AudioRaiseVolume, exec, swayosd-client --output-volume raise binde =, XF86AudioRaiseVolume, exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+
binde =, XF86AudioLowerVolume, exec, swayosd-client --output-volume lower binde =, XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-
bind =, XF86AudioMute, exec, swayosd-client --output-volume mute-toggle
bind =, XF86AudioMicMute, exec, swayosd-client --input-volume mute-toggle
bindr = CAPS, Caps_Lock, exec, swayosd-client --caps-lock bind =, XF86AudioMute, exec, pactl set-sink-mute @DEFAULT_SINK@ toggle
bind =, XF86AudioMicMute, exec, pactl set-source-mute @DEFAULT_SOURCE@ toggle
bindr = CAPS, Caps_Lock, exec, ags -r 'Brightness.fetchCapsState()'
# Brightness control # Brightness control
binde =, XF86MonBrightnessUp, exec, swayosd-client --brightness 5 binde =, XF86MonBrightnessUp, exec, ags -r 'Brightness.screen += 0.05'
binde =, XF86MonBrightnessDown, exec, swayosd-client --brightness -5 binde =, XF86MonBrightnessDown, exec, ags -r 'Brightness.screen -= 0.05'

View file

@ -1,51 +0,0 @@
window {
background: rgba(40, 42, 54, 0.8);
border: 2px solid rgba(189, 147, 249, 0.8);
}
trough {
background: #363847;
}
progress {
background: #79659f;
}
/* DEFAULT STYLE
window {
padding: 12px 20px;
border-radius: 999px;
border: none;
}
#container {
margin: 16px;
}
image, label {
color: @theme_fg_color;
}
progressbar:disabled,
image:disabled {
opacity: 0.5;
}
progressbar {
min-height: 6px;
border-radius: 999px;
background: transparent;
border: none;
}
trough {
min-height: inherit;
border-radius: inherit;
border: none;
background: alpha(@theme_fg_color, 0.5);
}
progress {
min-height: inherit;
border-radius: inherit;
border: none;
background: @theme_fg_color;
}*/

View file

@ -78,7 +78,7 @@
waydroid.enable = true; waydroid.enable = true;
}; };
# enable brightness control for swayosd # enable brightness control
programs.light.enable = true; programs.light.enable = true;
services.udev.extraRules = '' services.udev.extraRules = ''

View file

@ -4,8 +4,6 @@
in in
{ {
xdg.configFile = { xdg.configFile = {
"swayosd/style.css".source = symlink "${configDir}/swayosd/style.css";
"gtklock/config.ini".source = pkgs.writeText "config.ini" '' "gtklock/config.ini".source = pkgs.writeText "config.ini" ''
[main] [main]
modules=${builtins.concatStringsSep ";" [ modules=${builtins.concatStringsSep ";" [

View file

@ -72,7 +72,6 @@ in {
swww swww
swayidle swayidle
lisgd lisgd
swayosd
squeekboard squeekboard
xclip xclip
wl-clipboard wl-clipboard

View file

@ -22,8 +22,6 @@ updateVencord() {
# https://gitlab.com/mishakmak/pam-fprint-grosshack # https://gitlab.com/mishakmak/pam-fprint-grosshack
# https://github.com/tio/input-emulator # https://github.com/tio/input-emulator
# https://github.com/ErikReider/SwayOSD
# https://extension.7tv.gg/manifest.moz.json # https://extension.7tv.gg/manifest.moz.json
updateFirefoxAddons() { updateFirefoxAddons() {
echo "Updating firefox addons using mozilla-addons-to-nix" echo "Updating firefox addons using mozilla-addons-to-nix"