feat: get rid of all random bash scripts

This commit is contained in:
matt1432 2023-12-07 15:28:58 -05:00
parent bba90cd8b6
commit 441c06f83d
9 changed files with 101 additions and 100 deletions

View file

@ -1,13 +0,0 @@
#!/usr/bin/env bash
FILE="$HOME/.config/.heart"
toggle() {
if grep -q 󰣐 "$FILE"; then
echo  > "$FILE"
else
echo 󰣐 >> "$FILE"
fi
}
[[ "$1" == "toggle" ]] && toggle

View file

@ -1,32 +1,46 @@
import { ProgressBar, Overlay, Box } from 'resource:///com/github/Aylur/ags/widget.js'; import { Box, EventBox, Icon, Label, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
import Brightness from '../../../services/brightness.js'; import Brightness from '../../../services/brightness.js';
import Separator from '../../misc/separator.js'; import Separator from '../../misc/separator.js';
import Heart from './heart.js';
const SPACING = 25; const SPACING = 5;
const BAR_CUTOFF = 0.33;
export default () => Overlay({ const BrightnessPercentLabel = (props) => Label({
tooltipText: 'Brightness', ...props,
child: ProgressBar({
className: 'toggle-off brightness',
connections: [[Brightness, (self) => { connections: [[Brightness, (self) => {
self.value = Brightness.screen > BAR_CUTOFF ? self.label = `${Math.round(Brightness.screen * 100)}%`;
Brightness.screen :
BAR_CUTOFF;
}, 'screen']], }, 'screen']],
}), });
overlays: [ export default () => {
Box({ const rev = Revealer({
css: 'color: #CBA6F7;', transition: 'slide_right',
child: Box({
children: [ children: [
Separator(SPACING), Separator(SPACING),
Heart(), BrightnessPercentLabel(),
], ],
}), }),
});
const widget = EventBox({
onHover: () => {
rev.revealChild = true;
},
onHoverLost: () => {
rev.revealChild = false;
},
child: Box({
className: 'brightness',
children: [
Icon('display-brightness-symbolic'),
rev,
], ],
}); }),
});
widget.rev = rev;
return widget;
};

View file

@ -1,31 +1,46 @@
import { Box, Label } from 'resource:///com/github/Aylur/ags/widget.js'; import { Box, Label } from 'resource:///com/github/Aylur/ags/widget.js';
import { subprocess, execAsync } from 'resource:///com/github/Aylur/ags/utils.js'; import { execAsync, readFileAsync } from 'resource:///com/github/Aylur/ags/utils.js';
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
const { get_home_dir } = imports.gi.GLib;
import EventBox from '../../misc/cursorbox.js'; import EventBox from '../../misc/cursorbox.js';
const HeartState = Variable('');
const heartFile = `${get_home_dir()}/.cache/ags/.heart`;
export default () => EventBox({ const stateCmd = () => ['bash', '-c',
hpack: 'center', `echo ${HeartState.value === ''} > ${heartFile}`];
const monitorState = () => {
HeartState.connect('changed', () => {
execAsync(stateCmd()).catch(print);
});
};
// On launch
readFileAsync(heartFile).then((content) => {
HeartState.value = JSON.parse(content) ? '' : '󰣐';
monitorState();
}).catch(() => {
execAsync(stateCmd()).then(() => {
monitorState();
}).catch(print);
});
export default () => {
return EventBox({
onPrimaryClickRelease: () => { onPrimaryClickRelease: () => {
execAsync(['bash', '-c', '$AGS_PATH/heart.sh toggle']).catch(print); HeartState.value = HeartState.value === '' ? '󰣐' : '';
}, },
child: Box({ child: Box({
className: 'heart-toggle', className: 'heart-toggle',
vertical: false,
child: Label({ child: Label({
label: '', binds: [['label', HeartState, 'value']],
setup: (self) => {
subprocess(
['bash', '-c', 'tail -f /home/matt/.config/.heart'],
(output) => {
self.label = ` ${output}`;
},
);
},
}), }),
}), }),
}); });
};

View file

@ -4,6 +4,7 @@ import { Box, Label } from 'resource:///com/github/Aylur/ags/widget.js';
import Audio from './audio.js'; import Audio from './audio.js';
import Bluetooth from './bluetooth.js'; import Bluetooth from './bluetooth.js';
import Brightness from './brightness.js';
import KeyboardLayout from './keyboard-layout.js'; import KeyboardLayout from './keyboard-layout.js';
import Network from './network.js'; import Network from './network.js';
@ -34,6 +35,8 @@ export default () => EventBox({
KeyboardLayout(), KeyboardLayout(),
Brightness(),
Audio(), Audio(),
Bluetooth(), Bluetooth(),

View file

@ -3,9 +3,9 @@ import { Window, CenterBox, Box } from 'resource:///com/github/Aylur/ags/widget.
import Separator from '../misc/separator.js'; import Separator from '../misc/separator.js';
import Battery from './buttons/battery.js'; import Battery from './buttons/battery.js';
import Brightness from './buttons/brightness.js';
import Clock from './buttons/clock.js'; import Clock from './buttons/clock.js';
import CurrentWindow from './buttons/current-window.js'; import CurrentWindow from './buttons/current-window.js';
import Heart from './buttons/heart.js';
import NotifButton from './buttons/notif-button.js'; import NotifButton from './buttons/notif-button.js';
import OskToggle from './buttons/osk-toggle.js'; import OskToggle from './buttons/osk-toggle.js';
import QsToggle from './buttons/quick-settings.js'; import QsToggle from './buttons/quick-settings.js';
@ -64,7 +64,7 @@ export default () => Window({
endWidget: Box({ endWidget: Box({
hpack: 'end', hpack: 'end',
children: [ children: [
Brightness(), Heart(),
Separator(SPACING), Separator(SPACING),

View file

@ -3,6 +3,8 @@ import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
import Bluetooth from 'resource:///com/github/Aylur/ags/service/bluetooth.js'; import Bluetooth from 'resource:///com/github/Aylur/ags/service/bluetooth.js';
import { execAsync, readFileAsync, timeout } from 'resource:///com/github/Aylur/ags/utils.js'; import { execAsync, readFileAsync, timeout } from 'resource:///com/github/Aylur/ags/utils.js';
const { get_home_dir } = imports.gi.GLib;
import Brightness from '../services/brightness.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 Tablet from '../services/tablet.js';
@ -17,9 +19,9 @@ export default () => {
globalThis.closeAll = closeAll; globalThis.closeAll = closeAll;
// Persist Bluetooth state // Persist Bluetooth state
const bluetoothStateFile = '/home/matt/.cache/ags/.bluetooth'; const bluetoothFile = `${get_home_dir()}/.cache/ags/.bluetooth`;
const stateCmd = () => ['bash', '-c', const stateCmd = () => ['bash', '-c',
`echo ${Bluetooth.enabled} > ${bluetoothStateFile}`]; `echo ${Bluetooth.enabled} > ${bluetoothFile}`];
const monitorState = () => { const monitorState = () => {
Bluetooth.connect('notify::enabled', () => { Bluetooth.connect('notify::enabled', () => {
execAsync(stateCmd()).catch(print); execAsync(stateCmd()).catch(print);
@ -27,19 +29,15 @@ export default () => {
}; };
// On launch // On launch
readFileAsync(bluetoothStateFile) readFileAsync(bluetoothFile).then((content) => {
.then((content) => {
Bluetooth.enabled = JSON.parse(content); Bluetooth.enabled = JSON.parse(content);
timeout(1000, () => { timeout(1000, () => {
monitorState(); monitorState();
}); });
}) }).catch(() => {
.catch(() => { execAsync(stateCmd()).then(() => {
execAsync(stateCmd())
.then(() => {
monitorState(); monitorState();
}) }).catch(print);
.catch(print);
}); });

View file

@ -10,6 +10,12 @@
min-width: 53px; min-width: 53px;
} }
.heart-toggle {
font-size: 28px;
min-height: 40px;
color: #CBA6F7;
}
.notif-panel { .notif-panel {
font-size: 20px; font-size: 20px;
min-height: 37px; min-height: 37px;
@ -54,7 +60,8 @@
} }
.audio, .audio,
.bluetooth { .bluetooth,
.brightness {
padding: 0 10px; padding: 0 10px;
font-size: 20px; font-size: 20px;
margin-right: -10px; margin-right: -10px;
@ -103,20 +110,6 @@
} }
} }
.brightness {
trough {
margin-right: -50px;
progress {
margin-right: 50px;
margin-top: -30px;
border-radius: 80px;
min-height: 36px;
background: rgba(#5e497c, 0.8);
}
}
}
tooltip { tooltip {
background: rgba(0,0,0, 0.6); background: rgba(0,0,0, 0.6);
border-radius: 5px; border-radius: 5px;

View file

@ -2,15 +2,6 @@
configDir = config.vars.configDir; configDir = config.vars.configDir;
symlink = config.lib.file.mkOutOfStoreSymlink; symlink = config.lib.file.mkOutOfStoreSymlink;
in { in {
wayland.windowManager.hyprland = {
settings = {
env = [
"AGS_PATH, ${configDir}/ags/bin"
"HYPR_PATH, ${configDir}/hypr/scripts"
];
};
};
xdg.configFile = { xdg.configFile = {
"dolphinrc".source = symlink "${configDir}/dolphinrc"; "dolphinrc".source = symlink "${configDir}/dolphinrc";
"kdeglobals".source = symlink "${configDir}/kdeglobals"; "kdeglobals".source = symlink "${configDir}/kdeglobals";

View file

@ -2,7 +2,7 @@
home.packages = home.packages =
(with pkgs.python311Packages; [ (with pkgs.python311Packages; [
python python
pyclip pyclip # For Waydroid?
]) ])
++ (with pkgs; [ ++ (with pkgs; [
# Misc CLI # Misc CLI