Update to Debian trixie

This commit is contained in:
Jan Schär 2026-03-21 09:45:05 +01:00
parent 7a83c50208
commit 6118557715
12 changed files with 193 additions and 140 deletions

View file

@ -2,21 +2,27 @@
// Because of that, this gnome extension is distributed under
// the terms of the GNU General Public License, version 2 or later.
const {
AccountsService, Atk, Clutter, Gio,
GLib, Graphene, Meta, Shell, St,
} = imports.gi;
import AccountsService from 'gi://AccountsService';
import Atk from 'gi://Atk';
import Clutter from 'gi://Clutter';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import Graphene from 'gi://Graphene';
import Meta from 'gi://Meta';
import Shell from 'gi://Shell';
import St from 'gi://St';
const Background = imports.ui.background;
const Layout = imports.ui.layout;
const Main = imports.ui.main;
const ScreenShield = imports.ui.screenShield;
import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js';
import * as Background from 'resource:///org/gnome/shell/ui/background.js';
import * as Layout from 'resource:///org/gnome/shell/ui/layout.js';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as ScreenShield from 'resource:///org/gnome/shell/ui/screenShield.js';
// half of the time for which a frame is displayed
const HALF_FRAME_TIME_MS = 8;
const BLUR_BRIGHTNESS = 0.55;
const BLUR_SIGMA = 60;
const BLUR_BRIGHTNESS = 0.65;
const BLUR_RADIUS = 90;
const POINTER_HIDE_TIMEOUT = 10 * GLib.USEC_PER_SEC;
@ -43,6 +49,7 @@ let countdownTimeoutId = 0;
let configFile;
let configMonitor;
let configLoadCancellable;
let config;
let startTime;
@ -59,49 +66,47 @@ function extLogError (msg) {
printerr(`[contest-lock] Error: ${msg}`);
}
function loadConfig () {
configFile.load_contents_async(null, (obj, res) => {
// If there is a poblem with the config file, log an error and keep
// using the old config.
let newConfig;
try {
const [ok, bytes] = configFile.load_contents_finish(res);
// TextDecoder is used in upstream gnome-shell, but not yet
// supported in current Debian.
const contentStr = imports.byteArray.toString(bytes);
//const contentStr = new TextDecoder().decode(bytes);
newConfig = JSON.parse(contentStr);
} catch (err) {
logError(err, '[contest-lock] config file');
return;
}
if (!(typeof newConfig === 'object' && newConfig != null)) {
extLogError('config file: invalid format');
return;
}
if (typeof newConfig.title !== 'string') {
extLogError('config file: "title" must be a string');
return;
}
if (typeof newConfig.message !== 'string') {
extLogError('config file: "message" must be a string');
return;
}
if (
typeof newConfig.startTime !== 'string' ||
!/^\d{4,}-\d\d-\d\dT\d\d:\d\d:\d\d\+\d\d:\d\d$/.test(newConfig.startTime)
) {
extLogError('config file: "startTime" must be a string with format 0000-00-00T00:00:00+00:00');
return;
}
async function loadConfig () {
configLoadCancellable?.cancel();
configLoadCancellable = new Gio.Cancellable();
extLog('Loaded new config.')
config = newConfig;
startTime = (new Date(newConfig.startTime)).getTime();
// If there is a poblem with the config file, log an error and keep
// using the old config.
let newConfig;
try {
const [ok, bytes] = await configFile.load_contents(configLoadCancellable);
const contentStr = new TextDecoder().decode(bytes);
newConfig = JSON.parse(contentStr);
} catch (err) {
logError(err, '[contest-lock] config file');
return;
}
if (typeof newConfig !== 'object' || newConfig == null) {
extLogError('config file: invalid format');
return;
}
if (typeof newConfig.title !== 'string') {
extLogError('config file: "title" must be a string');
return;
}
if (typeof newConfig.message !== 'string') {
extLogError('config file: "message" must be a string');
return;
}
if (
typeof newConfig.startTime !== 'string' ||
!/^\d{4,}-\d\d-\d\dT\d\d:\d\d:\d\d\+\d\d:\d\d$/.test(newConfig.startTime)
) {
extLogError('config file: "startTime" must be a string with format 0000-00-00T00:00:00+00:00');
return;
}
updateConfig();
syncActive();
});
extLog('Loaded new config.')
config = newConfig;
startTime = (new Date(newConfig.startTime)).getTime();
updateConfig();
syncActive();
}
function syncActive () {
@ -190,7 +195,7 @@ function updateBackgrounds () {
effect: new Shell.BlurEffect({
name: 'blur',
brightness: BLUR_BRIGHTNESS,
sigma: BLUR_SIGMA,
radius: BLUR_RADIUS,
}),
});
@ -382,7 +387,9 @@ function deactivate () {
isActiveChanging = false;
}
function init (extension) {
var isInitialized = false;
function init () {
actor = Main.layoutManager.screenShieldGroup;
const userName = GLib.get_user_name();
@ -395,7 +402,7 @@ function init (extension) {
Main.layoutManager.connect('monitors-changed', updateBackgrounds);
cursorTracker = Meta.CursorTracker.get_for_display(global.display);
cursorTracker = global.backend.get_cursor_tracker();
if (!Main.layoutManager._startingUp) {
isShellReady = true;
@ -406,19 +413,6 @@ function init (extension) {
});
}
// TODO: When we drop compatibility with gnome <42, remove this code,
// rename the stylesheet back to stylesheet.css (so that it is loaded
// by the extension system) and add a session-modes property which
// includes unlock-dialog to metadata.json.
const theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
const stylesheetFile = extension.dir.get_child('stylesheet-always.css');
theme.load_stylesheet(stylesheetFile);
// TODO: When we drop compatibility with gnome <42, remove this code.
// gnome 38 has a bug that causes extensions to break when running
// `dconf update` while the screen is locked.
Main.extensionManager.reloadExtension = function () {};
configFile = Gio.File.new_for_path('/etc/contest-lock.json');
configMonitor = configFile.monitor_file(Gio.FileMonitorFlags.NONE, null);
configMonitor.set_rate_limit(1000);
@ -426,12 +420,18 @@ function init (extension) {
loadConfig();
}
function enable () {
isExtensionEnabled = true;
syncActive();
}
export default class ContestLockExtension extends Extension {
enable () {
if (!isInitialized) {
init();
isInitialized = true;
}
isExtensionEnabled = true;
syncActive();
}
function disable () {
isExtensionEnabled = false;
syncActive();
disable () {
isExtensionEnabled = false;
syncActive();
}
}

View file

@ -3,6 +3,7 @@
"uuid": "contest-lock@soi.ch",
"name": "Contest lock screen",
"description": "A custom lock screen for contests.",
"shell-version": [ "3.38", "42", "43" ],
"session-modes": [ "user", "unlock-dialog" ],
"shell-version": [ "48" ],
"url": ""
}

View file

@ -1,24 +1,24 @@
.contest-lock-stack {
color: white;
text-align: center;
spacing: 24px;
spacing: 32px;
}
.contest-lock-countdown {
font-size: 64pt;
font-size: 96pt;
font-weight: 300;
font-feature-settings: "tnum"; /* tabular figures */
}
.contest-lock-title {
font-size: 16pt;
font-size: 24pt;
}
.contest-lock-user {
font-size: 20pt;
font-size: 32pt;
}
.contest-lock-message {
padding-top: 24px;
font-size: 16pt;
padding-top: 32px;
font-size: 24pt;
}