feat: make various improvements to blend-settings
This commit is contained in:
parent
2e0016f941
commit
fd8d0cb9a8
4 changed files with 7 additions and 182 deletions
|
@ -18,7 +18,7 @@
|
|||
Containers</button>
|
||||
<button class="btn btn-outline-light shadow-none d-none" id="android-button" onclick="page('android')">Android
|
||||
Apps</button>
|
||||
<!-- <button class="btn btn-outline-light shadow-none" id="system-button" onclick="page('system')">System</button> -->
|
||||
<button class="btn btn-outline-light shadow-none" id="system-button" onclick="page('system')">System</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,96 +1,3 @@
|
|||
function rollback() {
|
||||
let rollback_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
let s = require('child_process').spawnSync('pkexec', ['blend-system', 'rollback']).status
|
||||
if (s === 0) {
|
||||
postMessage('success')
|
||||
} else {
|
||||
postMessage('failure')
|
||||
}
|
||||
`
|
||||
)
|
||||
rollback_worker.onmessage = e => {
|
||||
if (e.data == 'success') {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="undo_rollback()" id="rollback-btn">Cancel rollback</button>'
|
||||
} else {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" id="rollback-btn" disabled>Failed</button>'
|
||||
setTimeout(() => document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="rollback()" id="rollback-btn">Rollback</button>', 2000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function undo_rollback() {
|
||||
let undo_rollback_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
let s = require('child_process').spawnSync('pkexec', ['rm', '-f', '/blend/states/.load_prev_state']).status
|
||||
if (s === 0) {
|
||||
postMessage('success')
|
||||
} else {
|
||||
postMessage('failure')
|
||||
}
|
||||
`
|
||||
)
|
||||
undo_rollback_worker.onmessage = e => {
|
||||
if (e.data == 'success') {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="rollback()" id="rollback-btn">Rollback</button>'
|
||||
} else {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" id="rollback-btn" disabled>Failed</button>'
|
||||
setTimeout(() => document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="undo_rollback()" id="rollback-btn">Cancel rollback</button>', 2000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function save_state() {
|
||||
$("#settings-tabs").find("*").prop('disabled', true)
|
||||
|
||||
let save_state_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
let s = require('child_process').spawnSync('pkexec', ['blend-system', 'save-state']).status
|
||||
if (s === 0) {
|
||||
postMessage('success')
|
||||
} else {
|
||||
postMessage('failure')
|
||||
}
|
||||
`
|
||||
)
|
||||
save_state_worker.onmessage = e => {
|
||||
if (e.data == 'success') {
|
||||
document.getElementById('save-state-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-success" id="save-state-btn" disabled>Saved state</button>'
|
||||
$("#settings-tabs").find("*").prop('disabled', false)
|
||||
setTimeout(() => document.getElementById('save-state-btn').outerHTML =
|
||||
'<button type="button" id="save-state-btn" onclick="save_state()" class="btn btn-success">Save state</button>', 2000)
|
||||
} else {
|
||||
document.getElementById('save-state-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-success" id="save-state-btn" disabled>Failed</button>'
|
||||
$("#settings-tabs").find("*").prop('disabled', false)
|
||||
setTimeout(() => document.getElementById('save-state-btn').outerHTML =
|
||||
'<button type="button" id="save-state-btn" onclick="save_state()" class="btn btn-success">Save state</button>', 2000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function check_rollback() {
|
||||
if (require('fs').existsSync('/blend/states/.load_prev_state')) {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="undo_rollback()" id="rollback-btn">Cancel rollback</button>'
|
||||
} else {
|
||||
document.getElementById('rollback-btn').outerHTML =
|
||||
'<button type="button" class="btn btn-danger" onclick="rollback()" id="rollback-btn">Rollback</button>'
|
||||
}
|
||||
}
|
||||
|
||||
function check_state_creation() {
|
||||
if (require('fs').existsSync('/blend/states/.disable_states')) {
|
||||
document.getElementById('automatic-state-toggle').setAttribute('checked', '')
|
||||
}
|
||||
}
|
||||
|
||||
function check_app_grouping() {
|
||||
if (require('fs').existsSync(`${require('os').homedir()}/.config/categorize_apps_gnome_disable`)) {
|
||||
|
@ -99,48 +6,6 @@ function check_app_grouping() {
|
|||
}
|
||||
|
||||
check_app_grouping()
|
||||
check_state_creation()
|
||||
check_rollback()
|
||||
|
||||
$('#automatic-state-toggle').on('change', () => {
|
||||
if (!document.getElementById('automatic-state-toggle').checked) {
|
||||
let enable_autostate_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
let s = require('child_process').spawnSync('pkexec', ['rm', '-f', '/blend/states/.disable_states']).status
|
||||
if (s === 0) {
|
||||
postMessage('success')
|
||||
} else {
|
||||
postMessage('failure')
|
||||
}
|
||||
`
|
||||
)
|
||||
enable_autostate_worker.onmessage = e => {
|
||||
if (e.data == 'success') {
|
||||
document.getElementById('automatic-state-toggle').checked = false
|
||||
} else {
|
||||
document.getElementById('automatic-state-toggle').checked = true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let disable_autostate_worker = new Worker(
|
||||
`data:text/javascript,
|
||||
let s = require('child_process').spawnSync('pkexec', ['blend-system', 'toggle-states']).status
|
||||
if (s === 0) {
|
||||
postMessage('success')
|
||||
} else {
|
||||
postMessage('failure')
|
||||
}
|
||||
`
|
||||
)
|
||||
disable_autostate_worker.onmessage = e => {
|
||||
if (e.data == 'success') {
|
||||
document.getElementById('automatic-state-toggle').checked = true
|
||||
} else {
|
||||
document.getElementById('automatic-state-toggle').checked = false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#app-grouping-toggle').on('change', () => {
|
||||
if (!document.getElementById('app-grouping-toggle').checked) {
|
||||
|
|
|
@ -1,50 +1,8 @@
|
|||
<div class="container-fluid d-flex justify-content-center">
|
||||
<div class="col-12 col-lg-10 col-xl-8 mx-auto">
|
||||
<strong class="mb-0">System Settings</strong>
|
||||
<br><br>
|
||||
<div class="list-group mb-5 shadow">
|
||||
<div class="list-group-item">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<strong class="mb-0">Disable automatic state creation</strong>
|
||||
<p class="text-muted mb-0">blendOS creates copies of apps and config every 12 hours (and keeps the
|
||||
previous one).</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-check form-switch align-middle">
|
||||
<input class="form-check-input align-middle" type="checkbox" role="switch" id="automatic-state-toggle">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-group-item">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<strong class="mb-0">Save current state</strong>
|
||||
<p class="text-muted mb-0">Create a copy of the current system state, including apps and config.</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-check form-switch align-middle">
|
||||
<button type="button" id="save-state-btn" onclick="save_state()" class="btn btn-success">Save
|
||||
state</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-group-item">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
<strong class="mb-0">Rollback</strong>
|
||||
<p class="text-muted mb-0">Rollback to the most recent state on the next boot. (note: this is irreversible)
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<div class="form-check form-switch align-middle">
|
||||
<button type="button" class="btn btn-danger" onclick="rollback()" id="rollback-btn">Rollback</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="height: 0.75rem;"></div>
|
||||
<div class="list-group mb-3 shadow">
|
||||
<div class="list-group-item d-none" id="app-grouping-item">
|
||||
<div class="row align-items-center">
|
||||
<div class="col">
|
||||
|
|
|
@ -105,6 +105,8 @@ if [[ ! -f '/.init_blend.lock' ]]; then
|
|||
|
||||
###
|
||||
|
||||
echo 'nameserver 1.1.1.1' > /etc/resolv.conf
|
||||
|
||||
if command -v apt-get &>/dev/null; then
|
||||
apt-get update &>/dev/null
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -y install bash bc curl less wget apt-utils apt-transport-https dialog \
|
||||
|
@ -383,7 +385,7 @@ for full_file in /usr/share/applications/*.desktop; do
|
|||
mkdir -p "${HOME}/.local/share/blend/icons/${CONTAINER_NAME}_${file}"; cp "${line:5}" "${HOME}/.local/share/blend/icons/${CONTAINER_NAME}_${file}"
|
||||
echo "Icon=${HOME}/.local/share/blend/icons/${CONTAINER_NAME}_${file}/$(basename "${line:5}")" >> "${HOME}/.local/share/applications/blend;${CONTAINER_NAME};${file}"
|
||||
else
|
||||
ICON_PATH="$(find /usr/share/icons/hicolor -type f -iname "${line:5}.*" -print -quit 2>/dev/null)"
|
||||
ICON_PATH="$(find /usr/share/icons/hicolor -type f -iname "*${line:5}*" -print -quit 2>/dev/null)"
|
||||
mkdir -p "$(dirname "${ICON_PATH}" | sed 's/\/usr\/share/'"\/home\/${_uname}"'\/.local\/share/g')"
|
||||
FINAL_ICON_PATH="$(dirname "${ICON_PATH}" | sed 's/\/usr\/share/'"\/home\/${_uname}"'\/.local\/share/g')/$(echo "${file%.*}").$(basename "${ICON_PATH}" | sed 's/^.*\.//')"
|
||||
cp "${ICON_PATH}" "${FINAL_ICON_PATH}" &>/dev/null
|
||||
|
@ -445,7 +447,7 @@ inotifywait -m /usr/share/applications /usr/bin -e create,delete,move 2>/dev/nul
|
|||
mkdir -p "${HOME}/.local/share/blend/icons/${CONTAINER_NAME}_${file}"; cp "${line:5}" "${HOME}/.local/share/blend/icons/${CONTAINER_NAME}_${file}"
|
||||
echo "Icon=${HOME}/.local/share/blend/icons/${CONTAINER_NAME}_${file}/$(basename "${line:5}")" >> "${HOME}/.local/share/applications/blend;${CONTAINER_NAME};${file}"
|
||||
else
|
||||
ICON_PATH="$(find /usr/share/icons/hicolor -type f -iname "${line:5}.*" -print -quit 2>/dev/null)"
|
||||
ICON_PATH="$(find /usr/share/icons/hicolor -type f -iname "*${line:5}*" -print -quit 2>/dev/null)"
|
||||
mkdir -p "$(dirname "${ICON_PATH}" | sed 's/\/usr\/share/'"\/home\/${_uname}"'\/.local\/share/g')"
|
||||
FINAL_ICON_PATH="$(dirname "${ICON_PATH}" | sed 's/\/usr\/share/'"\/home\/${_uname}"'\/.local\/share/g')/$(echo "${file%.*}").$(basename "${ICON_PATH}" | sed 's/^.*\.//')"
|
||||
cp "${ICON_PATH}" "${FINAL_ICON_PATH}"
|
||||
|
|
Loading…
Reference in a new issue