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 Separator from '../../misc/separator.js';
import Heart from './heart.js';
const SPACING = 25;
const BAR_CUTOFF = 0.33;
const SPACING = 5;
export default () => Overlay({
tooltipText: 'Brightness',
const BrightnessPercentLabel = (props) => Label({
...props,
connections: [[Brightness, (self) => {
self.label = `${Math.round(Brightness.screen * 100)}%`;
}, 'screen']],
});
child: ProgressBar({
className: 'toggle-off brightness',
connections: [[Brightness, (self) => {
self.value = Brightness.screen > BAR_CUTOFF ?
Brightness.screen :
BAR_CUTOFF;
}, 'screen']],
}),
overlays: [
Box({
css: 'color: #CBA6F7;',
export default () => {
const rev = Revealer({
transition: 'slide_right',
child: Box({
children: [
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 { 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';
const HeartState = Variable('');
const heartFile = `${get_home_dir()}/.cache/ags/.heart`;
export default () => EventBox({
hpack: 'center',
const stateCmd = () => ['bash', '-c',
`echo ${HeartState.value === ''} > ${heartFile}`];
const monitorState = () => {
HeartState.connect('changed', () => {
execAsync(stateCmd()).catch(print);
});
};
onPrimaryClickRelease: () => {
execAsync(['bash', '-c', '$AGS_PATH/heart.sh toggle']).catch(print);
},
child: Box({
className: 'heart-toggle',
vertical: false,
child: Label({
label: '',
setup: (self) => {
subprocess(
['bash', '-c', 'tail -f /home/matt/.config/.heart'],
(output) => {
self.label = ` ${output}`;
},
);
},
}),
}),
// On launch
readFileAsync(heartFile).then((content) => {
HeartState.value = JSON.parse(content) ? '' : '󰣐';
monitorState();
}).catch(() => {
execAsync(stateCmd()).then(() => {
monitorState();
}).catch(print);
});
export default () => {
return EventBox({
onPrimaryClickRelease: () => {
HeartState.value = HeartState.value === '' ? '󰣐' : '';
},
child: Box({
className: 'heart-toggle',
child: Label({
binds: [['label', HeartState, 'value']],
}),
}),
});
};

View file

@ -4,6 +4,7 @@ import { Box, Label } from 'resource:///com/github/Aylur/ags/widget.js';
import Audio from './audio.js';
import Bluetooth from './bluetooth.js';
import Brightness from './brightness.js';
import KeyboardLayout from './keyboard-layout.js';
import Network from './network.js';
@ -34,6 +35,8 @@ export default () => EventBox({
KeyboardLayout(),
Brightness(),
Audio(),
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 Battery from './buttons/battery.js';
import Brightness from './buttons/brightness.js';
import Clock from './buttons/clock.js';
import CurrentWindow from './buttons/current-window.js';
import Heart from './buttons/heart.js';
import NotifButton from './buttons/notif-button.js';
import OskToggle from './buttons/osk-toggle.js';
import QsToggle from './buttons/quick-settings.js';
@ -64,7 +64,7 @@ export default () => Window({
endWidget: Box({
hpack: 'end',
children: [
Brightness(),
Heart(),
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 { 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 Pointers from '../services/pointers.js';
import Tablet from '../services/tablet.js';
@ -17,9 +19,9 @@ export default () => {
globalThis.closeAll = closeAll;
// Persist Bluetooth state
const bluetoothStateFile = '/home/matt/.cache/ags/.bluetooth';
const bluetoothFile = `${get_home_dir()}/.cache/ags/.bluetooth`;
const stateCmd = () => ['bash', '-c',
`echo ${Bluetooth.enabled} > ${bluetoothStateFile}`];
`echo ${Bluetooth.enabled} > ${bluetoothFile}`];
const monitorState = () => {
Bluetooth.connect('notify::enabled', () => {
execAsync(stateCmd()).catch(print);
@ -27,20 +29,16 @@ export default () => {
};
// On launch
readFileAsync(bluetoothStateFile)
.then((content) => {
Bluetooth.enabled = JSON.parse(content);
timeout(1000, () => {
monitorState();
});
})
.catch(() => {
execAsync(stateCmd())
.then(() => {
monitorState();
})
.catch(print);
readFileAsync(bluetoothFile).then((content) => {
Bluetooth.enabled = JSON.parse(content);
timeout(1000, () => {
monitorState();
});
}).catch(() => {
execAsync(stateCmd()).then(() => {
monitorState();
}).catch(print);
});
TouchGestures.addGesture({

View file

@ -10,6 +10,12 @@
min-width: 53px;
}
.heart-toggle {
font-size: 28px;
min-height: 40px;
color: #CBA6F7;
}
.notif-panel {
font-size: 20px;
min-height: 37px;
@ -54,7 +60,8 @@
}
.audio,
.bluetooth {
.bluetooth,
.brightness {
padding: 0 10px;
font-size: 20px;
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 {
background: rgba(0,0,0, 0.6);
border-radius: 5px;

View file

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

View file

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